Class: Toys::Runner
- Inherits:
-
Object
- Object
- Toys::Runner
- Defined in:
- lib/toys/runner.rb
Overview
An internal class that orchestrates execution of a tool.
Generaly, you should not need to use this class directly. Instead, run a tool using CLI#run.
Instance Method Summary collapse
-
#initialize(cli, tool_definition) ⇒ Runner
constructor
Create a runner for a particular tool in a particular CLI.
-
#run(args, verbosity: 0) ⇒ Integer
Run the tool, provided given arguments.
Constructor Details
#initialize(cli, tool_definition) ⇒ Runner
Create a runner for a particular tool in a particular CLI.
49 50 51 52 |
# File 'lib/toys/runner.rb', line 49 def initialize(cli, tool_definition) @cli = cli @tool_definition = tool_definition end |
Instance Method Details
#run(args, verbosity: 0) ⇒ Integer
Run the tool, provided given arguments.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/toys/runner.rb', line 62 def run(args, verbosity: 0) data = create_data(args, verbosity) parse_args(args, data) unless @tool_definition.argument_parsing_disabled? tool = @tool_definition.tool_class.new(@cli, data) @tool_definition.run_initializers(tool) original_level = @cli.logger.level @cli.logger.level = @cli.base_level - data[Tool::Keys::VERBOSITY] begin perform_execution(tool) ensure @cli.logger.level = original_level end end |