Skip to content

Commit

Permalink
Standardize "requires a subcommand" error message (#299)
Browse files Browse the repository at this point in the history
* Standardize "requires a subcommand" error message

Closes #298

* Reorder conditional
  • Loading branch information
JacobEvelyn authored Jun 26, 2020
1 parent 85792ea commit abbe8fb
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/gli/command_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit abbe8fb

Please sign in to comment.