Class: SpaceArchitect::CLI::List

Inherits:
Dry::CLI::Command
  • Object
show all
Includes:
GlobalOptions, Helpers
Defined in:
lib/space_architect/cli/list.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(**opts) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/space_architect/cli/list.rb', line 11

def call(**opts)
  setup_terminal(**opts.slice(:color, :colors))
  handle_errors do
    spaces = store.list
    if spaces.empty?
      terminal.say "No spaces found in #{terminal.path(project_config.spaces_dir)}"
      next
    end

    rows = spaces.map do |space|
      [space.status, display_date(space), space.title, terminal.path(space.path)]
    end
    terminal.say terminal.table(%w[Status Date Title Path], rows)
    CLI.record_outcome(Outcome.new(exit_code: 0))
  end
end