lib/bolt/bolt_option_parser.rb in bolt-2.44.0 vs lib/bolt/bolt_option_parser.rb in bolt-3.0.0

- old
+ new

@@ -4,19 +4,19 @@ require 'optparse' module Bolt class BoltOptionParser < OptionParser - PROJECT_PATHS = %w[project configfile boltdir].freeze - OPTIONS = { inventory: %w[targets query rerun description], + PROJECT_PATHS = %w[project].freeze + OPTIONS = { inventory: %w[targets query rerun], authentication: %w[user password password-prompt private-key host-key-check ssl ssl-verify], escalation: %w[run-as sudo-password sudo-password-prompt sudo-executable], run_context: %w[concurrency inventoryfile save-rerun cleanup], global_config_setters: PROJECT_PATHS + %w[modulepath], transports: %w[transport connect-timeout tty native-ssh ssh-command copy-command], display: %w[format color verbose trace], - global: %w[help version debug log-level clear-cache] }.freeze + global: %w[help version log-level clear-cache] }.freeze ACTION_OPTS = OPTIONS.values.flatten.freeze def get_help_text(subcommand, action = nil) case subcommand @@ -112,25 +112,10 @@ banner: PROJECT_MIGRATE_HELP } else { flags: OPTIONS[:global], banner: PROJECT_HELP } end - when 'puppetfile' - case action - when 'install' - { flags: OPTIONS[:global] + OPTIONS[:global_config_setters] + %w[puppetfile], - banner: PUPPETFILE_INSTALL_HELP } - when 'show-modules' - { flags: OPTIONS[:global] + OPTIONS[:global_config_setters], - banner: PUPPETFILE_SHOWMODULES_HELP } - when 'generate-types' - { flags: OPTIONS[:global] + OPTIONS[:global_config_setters], - banner: PUPPETFILE_GENERATETYPES_HELP } - else - { flags: OPTIONS[:global], - banner: PUPPETFILE_HELP } - end when 'script' case action when 'run' { flags: ACTION_OPTS + %w[tmpdir env-var], banner: SCRIPT_RUN_HELP } @@ -190,11 +175,10 @@ guide View guides for Bolt concepts and features inventory Show the list of targets an action would run on module Manage Bolt project modules plan Convert, create, show, and run Bolt plans project Create and migrate Bolt projects - puppetfile Install and list modules and generate type references script Upload a local script and run it remotely secret Create encryption keys and encrypt and decrypt values task Show and run Bolt tasks GUIDES @@ -574,59 +558,10 @@ DESCRIPTION Migrate a Bolt project to use current best practices and the latest version of configuration files. HELP - PUPPETFILE_HELP = <<~HELP - NAME - puppetfile - - USAGE - bolt puppetfile <action> [options] - - DESCRIPTION - Install and list modules and generate type references - - ACTIONS - generate-types Generate type references to register in plans - install Install modules from a Puppetfile into a project - show-modules List modules available to the Bolt project - HELP - - PUPPETFILE_GENERATETYPES_HELP = <<~HELP - NAME - generate-types - - USAGE - bolt puppetfile generate-types [options] - - DESCRIPTION - Generate type references to register in plans. - HELP - - PUPPETFILE_INSTALL_HELP = <<~HELP - NAME - install - - USAGE - bolt puppetfile install [options] - - DESCRIPTION - Install modules from a Puppetfile into a project - HELP - - PUPPETFILE_SHOWMODULES_HELP = <<~HELP - NAME - show-modules - - USAGE - bolt puppetfile show-modules [options] - - DESCRIPTION - List modules available to the Bolt project. - HELP - SCRIPT_HELP = <<~HELP NAME script USAGE @@ -789,19 +724,10 @@ @options[:rerun] = rerun end define('--noop', 'See what changes Bolt will make without actually executing the changes') do |_| @options[:noop] = true end - define('--description DESCRIPTION', - 'Deprecated. Description to use for the job') do |description| - Bolt::Logger.deprecate( - "description_cli_option", - "Command line option '--description' is deprecated, and will be "\ - "removed in Bolt 3.0." - ) - @options[:description] = description - end define('--params PARAMETERS', "Parameters to a task or plan as json, a json file '@<file>', or on stdin '-'") do |params| @options[:task_options] = parse_params(params) end define('-e', '--execute CODE', @@ -875,35 +801,14 @@ # When specified from the CLI, modulepath entries are relative to pwd @options[:modulepath] = modulepath.split(File::PATH_SEPARATOR).map do |moduledir| File.expand_path(moduledir) end end - define('--boltdir PATH', - 'Deprecated. Specify what project to load config from (default:', - 'autodiscovered from current working dir)') do |path| - Bolt::Logger.deprecate( - "boltdir_cli_option", - "Command line option '--boltdir' is deprecated, use '--project' instead." - ) - @options[:boltdir] = path - end define('--project PATH', 'Path to load the Bolt project from (default: autodiscovered from current dir)') do |path| @options[:project] = path end - define('--configfile PATH', - 'Deprecated. Specify where to load config from (default:', - '~/.puppetlabs/bolt/bolt.yaml). Directory containing bolt.yaml will be', - 'used as the project directory.') do |path| - Bolt::Logger.deprecate( - "configfile_cli_option", - "Command line option '--configfile' is deprecated, and " \ - "will be removed in Bolt 3.0. Use '--project' and provide the "\ - "directory path instead." - ) - @options[:configfile] = path - end define('--hiera-config PATH', 'Specify where to load Hiera config from (default: ~/.puppetlabs/bolt/hiera.yaml)') do |path| @options[:'hiera-config'] = File.expand_path(path) end define('-i', '--inventoryfile PATH', @@ -911,23 +816,10 @@ if ENV.include?(Bolt::Inventory::ENVIRONMENT_VAR) raise Bolt::CLIError, "Cannot pass inventory file when #{Bolt::Inventory::ENVIRONMENT_VAR} is set" end @options[:inventoryfile] = File.expand_path(path) end - define('--puppetfile PATH', - 'Deprecated. Specify a Puppetfile to use when installing modules.', - ' (default: ~/.puppetlabs/bolt/Puppetfile)', - 'Modules are installed in the current project.') do |path| - command = Bolt::Util.powershell? ? 'Update-BoltProject' : 'bolt project migrate' - Bolt::Logger.deprecate( - "puppetfile_cli_option", - "Command line option '--puppetfile' is deprecated, and will be removed "\ - "in Bolt 3.0. You can migrate to using the new module management "\ - "workflow using '#{command}'." - ) - @options[:puppetfile_path] = File.expand_path(path) - end define('--[no-]save-rerun', 'Whether to update the rerun file after this command.') do |save| @options[:'save-rerun'] = save end separator "\nREMOTE ENVIRONMENT OPTIONS" @@ -1015,18 +907,9 @@ @options[:help] = true end define('--version', 'Display the version') do |_| puts Bolt::VERSION raise Bolt::CLIExit - end - define('--debug', 'Display debug logging') do |_| - @options[:debug] = true - # We don't actually set '--log-level debug' here, but once the options are evaluated by - # the config class the end result is the same. - Bolt::Logger.deprecate( - "debug_cli_option", - "Command line option '--debug' is deprecated, set '--log-level debug' instead." - ) end define('--log-level LEVEL', "Set the log level for the console. Available options are", "trace, debug, info, warn, error, fatal, any.") do |level| @options[:log] = { 'console' => { 'level' => level } }