Skip to content

Commit

Permalink
Slightly more sensible error when no args required
Browse files Browse the repository at this point in the history
Replaces errors such as:
`<command> requires at least 0 argument: "<command>"`
with:
`<command> should have no arguments: "<command>"`
  • Loading branch information
Ross Duggan committed Nov 14, 2012
1 parent bdf13cb commit 8e0c8c9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/thor/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,12 @@ def handle_argument_error(task, error, arity=nil) #:nodoc:
msg = "#{basename} #{task.name}"
if arity
required = arity < 0 ? (-1 - arity) : arity
msg << " requires at least #{required} argument"
msg << "s" if required > 1
if required == 0
msg << " should have no arguments"
else
msg << " requires at least #{required} argument"
msg << "s" if required > 1
end
else
msg = "call #{msg} as"
end
Expand Down

0 comments on commit 8e0c8c9

Please sign in to comment.