Method: Leg::CLI#run

Defined in:
lib/leg/cli.rb

#run(args) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/leg/cli.rb', line 24

def run(args)
  args = ["help"] if args.empty?
  cmd_name = args.shift.downcase

  if cmd_name =~ /\A\d+\z/
    args.unshift(cmd_name)
    cmd_name = "step"
  end

  if cmd = Leg::Commands::LIST.find { |cmd| cmd.name == cmd_name }
    command = cmd.new(args, @config)
    command.opts[:quiet] = true if @options[:force_quiet]
    command.run
  else
    puts "There is no '#{cmd_name}' command. Run `leg help` for help."
  end
end