From abbe8fb263aef2f4924b715f86fd19afc7d2881d Mon Sep 17 00:00:00 2001 From: Jacob Evelyn Date: Fri, 26 Jun 2020 08:46:13 -0400 Subject: [PATCH] Standardize "requires a subcommand" error message (#299) * Standardize "requires a subcommand" error message Closes #298 * Reorder conditional --- lib/gli/command_support.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/gli/command_support.rb b/lib/gli/command_support.rb index ba8755d7..b6edb93b 100644 --- a/lib/gli/command_support.rb +++ b/lib/gli/command_support.rb @@ -166,12 +166,8 @@ def get_action(arguments) def generate_error_action(arguments) lambda { |global_options,options,arguments| - if am_subcommand? - if arguments.size > 0 - raise UnknownCommand,"Unknown command '#{arguments[0]}'" - else - raise BadCommandLine,"Command '#{name}' requires a subcommand" - end + if am_subcommand? && arguments.size > 0 + raise UnknownCommand,"Unknown command '#{arguments[0]}'" elsif have_subcommands? raise BadCommandLine,"Command '#{name}' requires a subcommand #{self.commands.keys.join(',')}" else