lib/bolt/bolt_option_parser.rb in bolt-1.35.0 vs lib/bolt/bolt_option_parser.rb in bolt-1.36.0

- old
+ new

@@ -27,11 +27,11 @@ banner: COMMAND_HELP } when 'file' { flags: ACTION_OPTS + %w[tmpdir], banner: FILE_HELP } when 'inventory' - { flags: OPTIONS[:inventory] + OPTIONS[:global] + %w[format inventoryfile boltdir configfile], + { flags: OPTIONS[:inventory] + OPTIONS[:global] + %w[format inventoryfile boltdir configfile detail], banner: INVENTORY_HELP } when 'group' { flags: OPTIONS[:global] + %w[format inventoryfile boltdir configfile], banner: GROUP_HELP } when 'plan' @@ -47,10 +47,19 @@ banner: PLAN_RUN_HELP } else { flags: ACTION_OPTS + %w[params compile-concurrency tmpdir], banner: PLAN_HELP } end + when 'project' + case action + when 'init' + { flags: OPTIONS[:global], + banner: PROJECT_INIT_HELP } + else + { flags: OPTIONS[:global], + banner: PROJECT_HELP } + end when 'puppetfile' case action when 'install' { flags: OPTIONS[:global] + OPTIONS[:global_config_setters], banner: PUPPETFILE_INSTALL_HELP } @@ -119,10 +128,11 @@ bolt secret createkeys Create new encryption keys bolt secret encrypt <plaintext> Encrypt a value bolt secret decrypt <encrypted> Decrypt a value bolt inventory show Show the list of targets an action would run on bolt group show Show the list of groups in the inventory + bolt project init Create a new Bolt project Run `bolt <subcommand> --help` to view specific examples. Available options are: HELP @@ -308,17 +318,36 @@ show Show the list of groups in the inventory Available options are: GROUP_HELP + PROJECT_HELP = <<~PROJECT_HELP + Usage: bolt project <action> + + Available actions are: + init Create a new Bolt project + + Available options are: + PROJECT_HELP + + PROJECT_INIT_HELP = <<~PROJECT_INIT_HELP + Usage: bolt project init [directory] + + Create a new Bolt project. + Specify a directory to create the Bolt project in. Defaults to the current working directory. + + Available options are: + PROJECT_INIT_HELP + def initialize(options) super() @options = options define('-n', '--nodes NODES', - 'Alias for --targets') do |nodes| + 'Alias for --targets', + 'Deprecated in favor of --targets') do |nodes| @options [:nodes] ||= [] @options[:nodes] << get_arg_input(nodes) end define('-t', '--targets TARGETS', 'Identifies the targets of command.', @@ -355,24 +384,27 @@ end define('-e', '--execute CODE', "Puppet manifest code to apply to the targets") do |code| @options[:code] = code end + define('--detail', 'Show resolved configuration for the targets') do |detail| + @options[:detail] = detail + end separator "\nAuthentication:" define('-u', '--user USER', 'User to authenticate as') do |user| @options[:user] = user end define('-p', '--password [PASSWORD]', - 'Password to authenticate with. Omit the value to prompt for the password.') do |password| - if password.nil? - STDOUT.print "Please enter your password: " - @options[:password] = STDIN.noecho(&:gets).chomp - STDOUT.puts - else - @options[:password] = password + 'Password to authenticate with') do |password| + # TODO: Remove deprecation message + unless password + msg = "Optional parameter for --password is deprecated and no longer prompts for password. " \ + "Use the prompt plugin instead to prompt for passwords." + raise Bolt::CLIError, msg end + @options[:password] = password end define('--private-key KEY', 'Private ssh key to authenticate with') do |key| @options[:'private-key'] = key end define('--[no-]host-key-check', 'Check host keys with SSH') do |host_key_check| @@ -388,18 +420,18 @@ separator "\nEscalation:" define('--run-as USER', 'User to run as using privilege escalation') do |user| @options[:'run-as'] = user end define('--sudo-password [PASSWORD]', - 'Password for privilege escalation. Omit the value to prompt for the password.') do |password| - if password.nil? - STDOUT.print "Please enter your privilege escalation password: " - @options[:'sudo-password'] = STDIN.noecho(&:gets).chomp - STDOUT.puts - else - @options[:'sudo-password'] = password + 'Password for privilege escalation') do |password| + # TODO: Remove deprecation message + unless password + msg = "Optional parameter for --sudo-password is deprecated and no longer prompts for password. " \ + "Use the prompt plugin instead to prompt for passwords." + raise Bolt::CLIError, msg end + @options[:'sudo-password'] = password end separator "\nRun context:" define('-c', '--concurrency CONCURRENCY', Integer, 'Maximum number of simultaneous connections (default: 100)') do |concurrency| @@ -420,10 +452,11 @@ define('--boltdir FILEPATH', 'Specify what Boltdir to load config from (default: autodiscovered from current working dir)') do |path| @options[:boltdir] = path end define('--configfile FILEPATH', - 'Specify where to load config from (default: ~/.puppetlabs/bolt/bolt.yaml)') do |path| + 'Specify where to load config from (default: ~/.puppetlabs/bolt/bolt.yaml). ' \ + 'Directory containing bolt.yaml will be used as the Boltdir.') do |path| @options[:configfile] = path end define('-i', '--inventoryfile FILEPATH', 'Specify where to load inventory from (default: ~/.puppetlabs/bolt/inventory.yaml)') do |path| if ENV.include?(Bolt::Inventory::ENVIRONMENT_VAR)