lib/catfish/cli.rb in catfish-0.0.5 vs lib/catfish/cli.rb in catfish-0.0.6

- old
+ new

@@ -20,23 +20,27 @@ desc 'init [OPTIONS]', 'Generates a templated catfish repo in the current working directory' long_desc <<-D TODO: Long description D method_option 'provisioners', type: :array, banner: 'A list of vagrant provisiners to use' + method_option 'local', type: :boolean, default: true, banner: 'Set up a local vm for use with vagrant' + method_option 'local-box', type: :string, banner: 'Vagrant box for use with local VM' + method_option 'local-box-url', type: :string, banner: 'Vagrant box url for use with local VM' + method_option 'managed', type: :boolean, default: false, banner: 'Set up capability for vagrant-managed-servers' + method_option 'managed-servers', type: :array, banner: 'Initial list of servers to include in Catfishfile' method_option 'communicator', type: :string, banner: 'The communicator. ssh (default) or winrm' method_option 'windows', type: :boolean, banner: 'Shorthand for --communicator=winrm' method_option 'winrm-username', type: :string, banner: 'Username for winrm. Used with --communicator=winrm' method_option 'winrm-password', type: :string, banner: 'Password for winrm. Used with --communicator=winrm' method_option 'shell', type: :boolean, banner: 'Shorthand for provisioners=shell' method_option 'shell-paths', type: :array, banner: 'A list of paths to use if shell provisioning is selected' method_option 'ssh-username', type: :string, banner: 'SSH username' method_option 'ssh-private-key-path', type: :string, banner: 'Path to SSH private key' method_option 'puppet', type: :boolean, banner: 'Shorthand for provisioners=puppet' - method_option 'puppet-librarian-puppet', type: :boolean, default: 'true', + method_option 'puppet-librarian-puppet', type: :boolean, default: true, banner: 'Whether or not to include a default Puppetfile and librarian puppet plugin' - method_option 'puppet-hiera', type: :boolean, default: 'true', banner: 'Include hiera templates. Only applies to puppet provisioner' - method_option 'servers', type: :array, banner: 'Initial list of servers to include in Catfishfile' + method_option 'puppet-hiera', type: :boolean, default: true, banner: 'Include hiera templates. Only applies to puppet provisioner' method_option 'plugins', type: :array, banner: 'Vagrant plugins to be installed' def init require 'catfish/cli/init' Init.new(options.dup, self).run end @@ -51,16 +55,27 @@ def plugin require 'catfish/cli/plugin' Plugin.new(options.dup).run end + desc 'clean', 'Clean Catfishfile.lock' + def clean + require 'catfish/cli/clean' + Clean.new.run + end + desc 'provision [OPTIONS]', 'Provision to the servers specified in Catfishfile.lock' method_option 'provider', type: :string, default: 'managed', banner: 'Vagrant provider to use.' - method_option 'parallel', type: :boolean, default: 'false', banner: 'Run provisioning in parallel' + method_option 'parallel', type: :boolean, default: false, banner: 'Run provisioning in parallel' def provision + exists_before_resolve = File.exist?('Catfishfile.lock') invoke :resolve invoke :plugin require 'catfish/cli/provision' Provision.new(options.dup).run + + # If the Catfishfile.lock existed before the start of the run, then + # we should leave it there. Otherwise, we should clean it up. + FileUtils.rm 'Catfishfile.lock', force: true unless exists_before_resolve end end end