class ChefDK::Command::Base
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/chef-dk/command/base.rb, line 45 def initialize super end
Public Instance Methods
check_license_acceptance()
click to toggle source
# File lib/chef-dk/command/base.rb, line 82 def check_license_acceptance LicenseAcceptance::Acceptor.check_and_persist!("chef-dk", ChefDK::VERSION.to_s) end
needs_help?(params)
click to toggle source
# File lib/chef-dk/command/base.rb, line 74 def needs_help?(params) params.include?("-h") || params.include?("--help") end
needs_version?(params)
click to toggle source
# File lib/chef-dk/command/base.rb, line 78 def needs_version?(params) params.include?("-v") || params.include?("--version") end
run_with_default_options(enforce_license, params = [ ])
click to toggle source
optparser overwrites -h / –help options with its own. In order to control this behavior, make sure the default options are handled here.
# File lib/chef-dk/command/base.rb, line 54 def run_with_default_options(enforce_license, params = [ ]) if needs_help?(params) msg(opt_parser.to_s) 0 elsif needs_version?(params) msg("#{ChefDK::Dist::PRODUCT} version: #{ChefDK::VERSION}") 0 else check_license_acceptance if enforce_license run(params) end rescue Chef::Exceptions::ConfigurationError => e err("ERROR: #{e.message}\n") 1 rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e err("ERROR: #{e.message}\n") msg(opt_parser) 1 end