Class: Ace::Demo::CLI::Commands::List

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/demo/cli/commands/list.rb

Instance Method Summary collapse

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ace/demo/cli/commands/list.rb', line 15

def call(**)
  tapes = Molecules::TapeScanner.new.list
  return puts("No demo tapes found.") if tapes.empty?

  puts "Available demo tapes:"
  width = tapes.map { |item| item[:name].length }.max

  tapes.each do |item|
    description = item[:description].to_s.strip
    description = "(no description)" if description.empty?
    format_label = (item[:format] == "yaml") ? "yaml" : "tape"
    puts format("  %-#{width}s  %-5s  %-40s  (%s)", item[:name], format_label, description, item[:source])
  end
rescue => e
  raise Ace::Support::Cli::Error, e.message
end