lib/berkshelf/cli.rb in berkshelf-0.3.7 vs lib/berkshelf/cli.rb in berkshelf-0.4.0.rc1

- old
+ new

@@ -6,10 +6,11 @@ class Cli < Thor def initialize(*) super # JW TODO: Replace Chef::Knife::UI with our own UI class ::Berkshelf.ui = Chef::Knife::UI.new(STDOUT, STDERR, STDIN, {}) + ::Berkshelf.config_path = @options[:config] @options = options.dup # unfreeze frozen options Hash from Thor rescue BerkshelfError => e Berkshelf.ui.fatal e exit e.status_code end @@ -21,11 +22,11 @@ map 'ud' => :update map 'ver' => :version class_option :config, type: :string, - default: File.expand_path(ENV["CHEF_CONFIG"] || "~/.chef/knife.rb"), + default: Berkshelf::DEFAULT_CONFIG, desc: "Path to Knife or Chef configuration to use.", aliases: "-c", banner: "PATH" method_option :shims, @@ -93,11 +94,11 @@ type: :boolean, default: false, desc: "Upload all cookbooks even if a frozen one exists on the target Chef Server" desc "upload", "Upload the Cookbooks specified by a Berksfile or a Berksfile.lock to a Chef Server." def upload - load_config + Berkshelf.load_config berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile]) berksfile.upload(Chef::Config[:chef_server_url], options) rescue BerkshelfError => e Berkshelf.ui.fatal e exit e.status_code @@ -132,14 +133,8 @@ "Berkshelf (#{Berkshelf::VERSION})" end def license File.read(Berkshelf.root.join('LICENSE')) - end - - def load_config - Chef::Config.from_file(File.expand_path(options[:config])) - rescue Errno::ENOENT - raise KnifeConfigNotFound, "Unable to find a Knife config at #{options[:config]}. Specify a different path with --config." end end end