Class: Roast::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/roast/cli.rb

Constant Summary collapse

COMMANDS =
["execute", "version", "help"].freeze

Class Method Summary collapse

Class Method Details

.start(argv) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/roast/cli.rb', line 9

def start(argv)
  roast_args, extra_args = split_at_separator(argv)

  show_help = false #: bool
  parser = OptionParser.new do |opts|
    opts.on("-h", "--help") { show_help = true }
  end
  parser.order!(roast_args)

  command = roast_args.first
  if show_help || command == "help"
    help
  elsif command == "version"
    puts "Roast version #{Roast::VERSION}"
  elsif command == "execute"
    roast_args.shift
    run_execute(roast_args, extra_args)
  elsif command && resolve_workflow_path(command)
    run_execute(roast_args, extra_args)
  elsif command
    $stderr.puts "Could not find command or workflow file \"#{command}\"\n\n"
    help
    exit(1)
  else
    help
  end
end