Class: Gherkin::Cli::Main

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

Class Method Summary collapse

Class Method Details

.die(msg) ⇒ Object



28
29
30
# File 'lib/gherkin/cli/main.rb', line 28

def self.die(msg)
  Trollop::die("#{msg}\nusage: gherkin COMMAND [ARGS]\nAvailable commands: #{Tools::SUB_COMMANDS.join(' ')}")
end

.run(args) ⇒ Object



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

def self.run(args)
  Trollop::options(args) do
    banner "Super fast gherkin parser"
    stop_on Tools::SUB_COMMANDS
  end

  cmd_name = args.shift
  die("Missing command") if cmd_name.nil?
  begin
    cmd = Tools.const_get(cmd_name.capitalize.to_sym).new(args)
    cmd.run
  rescue => e
    Trollop::die(e.message + "\n#{e.backtrace.join("\n")}\n\nCommand: #{cmd_name}")
  end
end