diff options
-rw-r--r-- | lib/chef/knife.rb | 8 | ||||
-rw-r--r-- | lib/chef/knife/core/subcommand_loader.rb | 2 |
2 files changed, 7 insertions, 3 deletions
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 diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb index 146411a399..fb3723de50 100644 --- a/lib/chef/knife/core/subcommand_loader.rb +++ b/lib/chef/knife/core/subcommand_loader.rb @@ -142,7 +142,7 @@ class Chef words = words.dup match = nil until match || words.empty? - candidate = words.join(sep) + candidate = words.join(sep).tr("-", "_") if hash.key?(candidate) match = candidate else |