Class: Ergane::Runner
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(root, argv) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
5 6 7 |
# File 'lib/ergane/runner.rb', line 5 def argv @argv end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ergane/runner.rb', line 12 def execute command_class, remaining, path = resolve(root, argv) if help_requested?(remaining) $stdout.puts HelpFormatter.new(command_class, command_path: path).format return end if version_requested?(remaining) && command_class.respond_to?(:version) && command_class.version $stdout.puts "#{command_class.command_name} #{command_class.version}" return end instance = command_class.new(remaining) instance.run(*instance.args) end |