Class: ChefDK::Command::Base
- Inherits:
-
Object
- Object
- ChefDK::Command::Base
- Includes:
- Helpers, Mixlib::CLI
- Defined in:
- lib/chef-dk/command/base.rb
Direct Known Subclasses
Exec, GemForwarder, Generate, GeneratorCommands::Base, ShellInit, Verify
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #needs_help?(params) ⇒ Boolean
- #needs_version?(params) ⇒ Boolean
-
#run_with_default_options(params = [ ]) ⇒ Object
optparser overwrites -h / –help options with its own.
Methods included from Helpers
#err, #msg, #omnibus_apps_dir, #omnibus_bin_dir, #omnibus_embedded_bin_dir, #omnibus_root, #stderr, #stdout, #system_command
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
40 41 42 |
# File 'lib/chef-dk/command/base.rb', line 40 def initialize super end |
Instance Method Details
#needs_help?(params) ⇒ Boolean
61 62 63 |
# File 'lib/chef-dk/command/base.rb', line 61 def needs_help?(params) params.include?("-h") || params.include?("--help") end |
#needs_version?(params) ⇒ Boolean
65 66 67 |
# File 'lib/chef-dk/command/base.rb', line 65 def needs_version?(params) params.include?("-v") || params.include?("--version") end |
#run_with_default_options(params = [ ]) ⇒ Object
optparser overwrites -h / –help options with its own. In order to control this behavior, make sure the default options are handled here.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/chef-dk/command/base.rb', line 49 def (params = [ ]) if needs_help?(params) msg(opt_parser.to_s) 0 elsif needs_version?(params) msg("Chef Development Kit Version: #{ChefDK::VERSION}") 0 else run(params) end end |