Class: OptparseLite::Dispatcher
- Inherits:
-
Object
- Object
- OptparseLite::Dispatcher
- Includes:
- HelpHelper
- Defined in:
- lib/optparse-lite.rb
Instance Attribute Summary collapse
-
#help ⇒ Object
readonly
commands need some or all of these.
-
#impl ⇒ Object
readonly
commands need some or all of these.
-
#spec ⇒ Object
readonly
commands need some or all of these.
-
#ui ⇒ Object
readonly
commands need some or all of these.
Instance Method Summary collapse
-
#initialize(impl, spec, ui) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #run(argv) ⇒ Object
Methods included from HelpHelper
#cmd, #hdr, #help_requested?, #looks_like_header?, #prefix, #txt
Constructor Details
#initialize(impl, spec, ui) ⇒ Dispatcher
Returns a new instance of Dispatcher.
293 294 295 296 297 298 |
# File 'lib/optparse-lite.rb', line 293 def initialize impl, spec, ui @impl = impl @spec = spec @ui = ui @help = Help.new(@spec, @ui) end |
Instance Attribute Details
#help ⇒ Object (readonly)
commands need some or all of these
300 301 302 |
# File 'lib/optparse-lite.rb', line 300 def help @help end |
#impl ⇒ Object (readonly)
commands need some or all of these
300 301 302 |
# File 'lib/optparse-lite.rb', line 300 def impl @impl end |
#spec ⇒ Object (readonly)
commands need some or all of these
300 301 302 |
# File 'lib/optparse-lite.rb', line 300 def spec @spec end |
#ui ⇒ Object (readonly)
commands need some or all of these
300 301 302 |
# File 'lib/optparse-lite.rb', line 300 def ui @ui end |
Instance Method Details
#run(argv) ⇒ Object
301 302 303 304 305 306 307 308 309 |
# File 'lib/optparse-lite.rb', line 301 def run argv return @help.no_args if argv.empty? return @help.requested(argv) if help_requested?(argv) if cmd = @help.find_one_loudly(argv.shift, @spec) cmd.run(self, argv) else -1 # kind of silly but whatever end end |