Class: Space::Src::CLI::Shell::Complete

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

Instance Method Summary collapse

Instance Method Details

#call(kind:, extra: []) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/space_src/cli/shell.rb', line 91

def call(kind:, extra: [], **)
  case kind
  when "checkouts"
    begin
      paths = CLI.make_paths
      config = Config::Store.load(paths.config_file).success
      Nav.scan(config.base_dir).each { |e| out.puts e[:target] }
    rescue
      # Never raise on a completion call — missing/unparseable config is fine.
    end
    CLI.record_outcome(Outcome.new(exit_code: 0))
  when "shells"
    out.puts "fish"
    CLI.record_outcome(Outcome.new(exit_code: 0))
  else
    err.puts "Usage: src shell complete checkouts|shells"
    CLI.record_outcome(Outcome.new(exit_code: 1))
  end
rescue => e
  err.puts "src shell complete: #{e.message}"
  CLI.record_outcome(Outcome.new(exit_code: 1))
end