From c78512254c655de1d66d0a300b5a7db4cd09adce Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 10 Jul 2018 18:47:18 -0700 Subject: Add support for knife commands with hyphens. This works exactly like with an underscore, but is a bit more user-friendly sometimes (e.g. `get_config` vs `get-config`). Signed-off-by: Noah Kantrowitz --- lib/chef/knife.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/chef/knife.rb') diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index e28ca81f71..6e525bdf3d 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -304,8 +304,12 @@ class Chef # knife node run_list add requires that we have extra logic to handle # the case that command name words could be joined by an underscore :/ - command_name_words = command_name_words.join("_") - @name_args.reject! { |name_arg| command_name_words == name_arg } + command_name_joined = command_name_words.join("_") + @name_args.reject! { |name_arg| command_name_joined == name_arg } + + # Similar handling for hyphens. + command_name_joined = command_name_words.join("-") + @name_args.reject! { |name_arg| command_name_joined == name_arg } if config[:help] msg opt_parser -- cgit v1.2.1