Class: EchSpec::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/echspec/cli.rb,
lib/echspec/cli/run.rb,
lib/echspec/cli/gen_configs.rb

Defined Under Namespace

Classes: GenConfigs, Run

Instance Method Summary collapse

Instance Method Details

#execute(argv = ARGV) ⇒ Object



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

def execute(argv = ARGV)
  subcommands = %i[run gen_configs]

  op = OptionParser.new

  op.banner = <<~USAGE
    Usage: echspec {SUBCOMMAND}

    Available subcommands: #{subcommands.join(', ')}, version, help.
  USAGE

  op.version = EchSpec::VERSION
  op.order!(argv)

  subcommand = argv.shift
  case subcommand&.to_sym
  when :version
    puts EchSpec::VERSION
  when *subcommands
    klass = self.class.const_get(subcommand.to_camel)
    klass.new.__send__(:execute, argv)
  else
    puts op
  end
end