Class: Bookbinder::CommandRunner
- Inherits:
-
Object
- Object
- Bookbinder::CommandRunner
- Defined in:
- lib/bookbinder/command_runner.rb
Instance Method Summary collapse
-
#initialize(logger, commands) ⇒ CommandRunner
constructor
A new instance of CommandRunner.
- #run(command_name, command_arguments) ⇒ Object
Constructor Details
#initialize(logger, commands) ⇒ CommandRunner
Returns a new instance of CommandRunner.
5 6 7 8 |
# File 'lib/bookbinder/command_runner.rb', line 5 def initialize(logger, commands) @logger = logger @commands = commands end |
Instance Method Details
#run(command_name, command_arguments) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/bookbinder/command_runner.rb', line 10 def run(command_name, command_arguments) command = commands.detect { |known_command| known_command.command_for?(command_name) } command.run(command_arguments) rescue CliError::InvalidArguments logger.log ["bookbinder #{command.usage[0]}", command.usage[1]] 1 end |