Class: Space::Src::CLI::Shell::Fish

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/space_src/cli/shell.rb

Instance Method Summary collapse

Instance Method Details

#call(subcommand: "install", force: false) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/space_src/cli/shell.rb', line 27

def call(subcommand: "install", force: false, **)
  case subcommand
  when "install"
    result = ShellIntegration.install("fish", env: CLI.env, force: force)
    out.puts fish_install_message(result.fetch(:action), result.fetch(:path))
    out.puts fish_completions_install_message(result.fetch(:completions_action), result.fetch(:completions_path))
    out.puts "Restart fish to load the integration in this terminal: exec fish"
    CLI.record_outcome(Outcome.new(exit_code: 0))
  when "uninstall"
    result = ShellIntegration.uninstall("fish", env: CLI.env, force: force)
    out.puts fish_uninstall_message(result.fetch(:action), result.fetch(:path))
    out.puts fish_completions_uninstall_message(result.fetch(:completions_action), result.fetch(:completions_path))
    CLI.record_outcome(Outcome.new(exit_code: 0))
  when "path"
    out.puts "Function:    #{ShellIntegration.path_for("fish", env: CLI.env)}"
    out.puts "Completions: #{ShellIntegration.completions_path_for("fish", env: CLI.env)}"
    CLI.record_outcome(Outcome.new(exit_code: 0))
  else
    err.puts "Usage: src shell fish [install|uninstall|path]"
    CLI.record_outcome(Outcome.new(exit_code: 1))
  end
rescue => e
  err.puts "src shell fish: #{e.message}"
  CLI.record_outcome(Outcome.new(exit_code: 1))
end