Class: WhirledPeas::CommandLine
- Inherits:
-
Object
- Object
- WhirledPeas::CommandLine
- Defined in:
- lib/whirled_peas/command_line.rb
Constant Summary collapse
- COMMANDS =
[ Command::Debug, Command::Fonts, Command::Frames, Command::Help, Command::Play, Command::Record, Command::Still, Command::Themes ].map.with_object({}) { |c, h| h[c.command_name] = c }
Instance Method Summary collapse
-
#initialize(args) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #start ⇒ Object
Constructor Details
#initialize(args) ⇒ CommandLine
Returns a new instance of CommandLine.
23 24 25 |
# File 'lib/whirled_peas/command_line.rb', line 23 def initialize(args) @args = args end |
Instance Method Details
#start ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/whirled_peas/command_line.rb', line 27 def start if args.length < 1 print_usage exit(1) end command = args.shift unless COMMANDS.key?(command) puts "Unrecognized command: #{command}" print_usage exit(1) end cmd = COMMANDS[command].new(args, WhirledPeas.config) unless cmd.valid? cmd.print_error exit(1) end cmd.start end |