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

- old
+ new

@@ -8,21 +8,19 @@ 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 namespace "berkshelf" map 'in' => :install map 'up' => :upload map 'ud' => :update map 'ver' => :version + map 'book' => :cookbook class_option :config, type: :string, default: Berkshelf::DEFAULT_CONFIG, desc: "Path to Knife or Chef configuration to use.", @@ -48,13 +46,10 @@ banner: "PATH" desc "install", "Install the Cookbooks specified by a Berksfile or a Berskfile.lock." def install berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile]) berksfile.install(options) - rescue BerkshelfError => e - Berkshelf.ui.fatal e - exit e.status_code end method_option :berksfile, type: :string, default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME), @@ -68,13 +63,10 @@ aliases: "-w" desc "update", "Update all Cookbooks and their dependencies specified by a Berksfile to their latest versions." def update Lockfile.remove! invoke :install - rescue BerkshelfError => e - Berkshelf.ui.fatal e - exit e.status_code end method_option :berksfile, type: :string, default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME), @@ -97,35 +89,61 @@ desc "upload", "Upload the Cookbooks specified by a Berksfile or a Berksfile.lock to a Chef Server." def upload 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 end - desc "init [PATH]", "Prepare a local path to have it's Cookbook dependencies managed by Berkshelf." + desc "init [PATH]", "Prepare a local path to have its Cookbook dependencies managed by Berkshelf." def init(path = Dir.pwd) if File.chef_cookbook?(path) options[:chefignore] = true options[:metadata_entry] = true end - generator = ::Berkshelf::InitGenerator.new([path], options) - generator.invoke_all + ::Berkshelf::InitGenerator.new([path], options).invoke_all ::Berkshelf.ui.info "Successfully initialized" - rescue BerkshelfError => e - Berkshelf.ui.fatal e - exit e.status_code end desc "version", "Display version and copyright information" def version Berkshelf.ui.info version_header Berkshelf.ui.info "\n" Berkshelf.ui.info license + end + + method_option :vagrant, + type: :boolean, + desc: "Creates a Vagrantfile and dynamically change other generated files to support Vagrant" + method_option :git, + type: :boolean, + desc: "Creates additional git specific files if your project will be managed by git" + method_option :foodcritic, + type: :boolean, + desc: "Creates a Thorfile with Foodcritic support to lint test your cookbook" + method_option :scmversion, + type: :boolean, + desc: "Creates a Thorfile with SCMVersion support to manage versions for continuous integration" + method_option :no_bundler, + type: :boolean, + desc: "Skips generation of a Gemfile and other Bundler specific support" + method_option :license, + type: :string, + default: "reserved", + desc: "License for cookbook (apachev2, gplv2, gplv3, mit, reserved)", + aliases: "-L" + method_option :maintainer, + type: :string, + desc: "Name of cookbook maintainer", + aliases: "-m" + method_option :maintainer_email, + type: :string, + desc: "Email address of cookbook maintainer", + aliases: "-e" + desc "cookbook NAME", "Create a skeleton for a new cookbook" + def cookbook(name) + ::Berkshelf::CookbookGenerator.new([name, File.join(Dir.pwd, name)], options).invoke_all end private def version_header