Class: Smartdict::Core::CommandManager

Inherits:
Object
  • Object
show all
Includes:
Smartdict::Commands, IsManager
Defined in:
lib/smartdict/core/command_manager.rb

Class Method Summary collapse

Methods included from IsManager

included

Class Method Details

.run(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/smartdict/core/command_manager.rb', line 11

def self.run(args)
  first_arg = args.shift
  case first_arg
  when nil, '-h', '--help', 'help'
    run_command :help, args
  when nil, '-v', '--version', 'version'
    run_command :version, args
  else
    run_command(first_arg, args)
  end
end

.run_command(name, args = []) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/smartdict/core/command_manager.rb', line 23

def self.run_command(name, args = [])
  if command = find(name)
    command.run(args)
  else
    abort "Unknown command: #{name}"
  end
end