Class: SpaceArchitect::CLI::Shell::Fish

Inherits:
Dry::CLI::Command
  • Object
show all
Includes:
GlobalOptions, Helpers
Defined in:
lib/space_architect/cli/shell.rb

Instance Method Summary collapse

Methods included from Helpers

#display_date, #handle_errors, #project_config, #render, #setup_terminal, #state, #store, #terminal

Methods included from GlobalOptions

included

Instance Method Details

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



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

def call(subcommand: "install", force: false, **opts)
  setup_terminal(**opts.slice(:color, :colors))
  handle_errors do
    case subcommand
    when "install"
      result = ShellIntegration.install("fish", env: project_config.env, force: force)
      terminal.success fish_install_message(result.fetch(:action), result.fetch(:path))
      terminal.success fish_completions_install_message(result.fetch(:completions_action), result.fetch(:completions_path))
      terminal.say "Restart fish to load the integration in this terminal: exec fish"
    when "uninstall"
      result = ShellIntegration.uninstall("fish", env: project_config.env, force: force)
      terminal.success fish_uninstall_message(result.fetch(:action), result.fetch(:path))
      terminal.success fish_completions_uninstall_message(result.fetch(:completions_action), result.fetch(:completions_path))
    when "path"
      terminal.say "Function:    #{terminal.path(ShellIntegration.path_for('fish', env: project_config.env))}"
      terminal.say "Completions: #{terminal.path(ShellIntegration.completions_path_for('fish', env: project_config.env))}"
    else
      err.puts "Usage: space shell fish [install|uninstall|path]"
      CLI.record_outcome(Outcome.new(exit_code: 1))
      next
    end
    CLI.record_outcome(Outcome.new(exit_code: 0))
  end
end