Revert UsageOnMissing.
This was breaking UsageOnMissing() when combined with validation of positional arguments, in that it was allowing positional arguments to be omitted. It also broke UsageOnMissing() somehow so that it did not work.
This commit is contained in:
+7
-7
@@ -683,14 +683,8 @@ func (c *Context) Run(binds ...interface{}) (err error) {
|
||||
defer catch(&err)
|
||||
node := c.Selected()
|
||||
if node == nil {
|
||||
if c.Kong.usageOnMissing {
|
||||
return c.PrintUsage(false)
|
||||
}
|
||||
return fmt.Errorf("no command selected")
|
||||
}
|
||||
if c.Kong.usageOnMissing && isMissingChildError(c.Error) {
|
||||
return c.PrintUsage(false)
|
||||
}
|
||||
return c.RunNode(node, binds...)
|
||||
}
|
||||
|
||||
@@ -759,7 +753,13 @@ func checkMissingChildren(node *Node) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
return newMissingChildError(missing)
|
||||
if len(missing) > 5 {
|
||||
missing = append(missing[:5], "...")
|
||||
}
|
||||
if len(missing) == 1 {
|
||||
return fmt.Errorf("expected %s", missing[0])
|
||||
}
|
||||
return fmt.Errorf("expected one of %s", strings.Join(missing, ", "))
|
||||
}
|
||||
|
||||
// If we're missing any positionals and they're required, return an error.
|
||||
|
||||
Reference in New Issue
Block a user