commands/cli: Fixed Parse required argument check
Matt Bell committed
Nov 17, 2014 at 01:38 UTC
d4ac442838aec986891b7efc5e6f6f11ae5df407
1 file changed
+5
-3
commands/cli/parse.go
+5
-3
@@ -249,9 +249,11 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi
249
}
250
251
// check to make sure we didn't miss any required arguments
252
- for _, argDef := range argDefs[argDefIndex:] {
253
- if argDef.Required {
254
- return nil, nil, fmt.Errorf("Argument '%s' is required", argDef.Name)
252
+ if len(argDefs) > argDefIndex {
253
+ for _, argDef := range argDefs[argDefIndex:] {
254
+ if argDef.Required {
255
+ return nil, nil, fmt.Errorf("Argument '%s' is required", argDef.Name)
256
+ }
257
}
258
}
259