Class: Ace::Demo::CLI::Commands::Create

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

Instance Method Summary collapse

Instance Method Details

#call(name:, args: [], **options) ⇒ 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
52
# File 'lib/ace/demo/cli/commands/create.rb', line 27

def call(name:, args: [], **options)
  commands = collect_commands(args)

  creator = Organisms::TapeCreator.new
  result = creator.create(
    name: name,
    commands: commands,
    description: options[:desc],
    tags: options[:tags],
    font_size: options[:font_size],
    width: options[:width],
    height: options[:height],
    timeout: options[:timeout],
    format: options[:format],
    force: options[:force],
    dry_run: options[:dry_run]
  )

  if result[:dry_run]
    puts result[:content]
  else
    puts "Created: #{result[:path]}"
  end
rescue TapeAlreadyExistsError => e
  raise Ace::Support::Cli::Error, e.message
end