summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-05-02 22:24:59 -0700
committerTim Smith <tsmith@chef.io>2019-05-02 22:24:59 -0700
commit385123ec906cacd37e5d599379d856a1ee4a088d (patch)
tree19a23c28b661dbbb7d9e3b65bea62137b08eac1e
parent21dae573adc3989ae1c7a0d6a0cebce41b84e483 (diff)
downloadchef-385123ec906cacd37e5d599379d856a1ee4a088d.tar.gz
Provide a friendly list of supported options in help
Makes for much better output: Valid choices are plaintext kerberos ssl negotiate. vs Valid choices are 'plaintext', 'kerberos', 'ssl' and 'negotiate'. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/knife/bootstrap.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 1d1946044f..2ecaf2ee34 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -28,6 +28,15 @@ class Chef
SUPPORTED_CONNECTION_PROTOCOLS = %w{ssh winrm}.freeze
WINRM_AUTH_PROTOCOL_LIST = %w{plaintext kerberos ssl negotiate}.freeze
+ # @param opt_arry [Array]
+ #
+ # @return [String] a friendly quoted list of items complete with "and"
+ def self.friendly_opt_list(opt_array)
+ opts = opt_array.map { |x| "'#{x}'" }
+ return opts.join(" and ") if opts.size < 3
+ opts[0..-2].join(", ") + " and " + opts[-1]
+ end
+
# Common connectivity options
option :connection_user,
short: "-U USERNAME",
@@ -47,7 +56,7 @@ class Chef
option :connection_protocol,
short: "-o PROTOCOL",
long: "--connection-protocol PROTOCOL",
- description: "The protocol to use to connect to the target node. Supports: #{SUPPORTED_CONNECTION_PROTOCOLS.join(" ")}"
+ description: "The protocol to use to connect to the target node. Supports: #{friendly_opt_list(SUPPORTED_CONNECTION_PROTOCOLS)}."
option :max_wait,
short: "-W SECONDS",
@@ -76,7 +85,7 @@ class Chef
option :winrm_auth_method,
short: "-w AUTH-METHOD",
long: "--winrm-auth-method AUTH-METHOD",
- description: "The WinRM authentication method to use. Valid choices are #{WINRM_AUTH_PROTOCOL_LIST}",
+ description: "The WinRM authentication method to use. Valid choices are #{friendly_opt_list(WINRM_AUTH_PROTOCOL_LIST)}.",
proc: Proc.new { |protocol| Chef::Config[:knife][:winrm_auth_method] = protocol }
option :winrm_basic_auth_only,