Class: Caterer::Command::Base
- Inherits:
-
Object
- Object
- Caterer::Command::Base
- Includes:
- Vli::Util::SafePuts
- Defined in:
- lib/caterer/command/base.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv, env) ⇒ Base
constructor
A new instance of Base.
- #parse_options(opts = nil, force_argv = false) ⇒ Object
Constructor Details
#initialize(argv, env) ⇒ Base
Returns a new instance of Base.
10 11 12 13 |
# File 'lib/caterer/command/base.rb', line 10 def initialize(argv, env) @argv = argv @env = env end |
Instance Method Details
#execute ⇒ Object
15 |
# File 'lib/caterer/command/base.rb', line 15 def execute; end |
#parse_options(opts = nil, force_argv = false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/caterer/command/base.rb', line 17 def (opts=nil, force_argv=false) argv = @argv.dup opts ||= OptionParser.new opts.on_tail("-h", "--help", "Print this help") do safe_puts(opts.help) return nil end begin opts.parse!(argv) raise if force_argv and (not argv or argv.length == 0) argv rescue safe_puts(opts.help) nil end end |