mirror of
https://github.com/ipfs/kubo.git
synced 2025-08-06 19:44:01 +08:00
commands/cli: Fixed parse bug when optional argument is defined first
This commit is contained in:
@ -182,9 +182,11 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi
|
||||
argDef := getArgDef(argDefIndex, argDefs)
|
||||
|
||||
// skip optional argument definitions if there aren't sufficient remaining inputs
|
||||
if numInputs-i <= numRequired && !argDef.Required {
|
||||
continue
|
||||
} else if argDef.Required {
|
||||
for numInputs-i <= numRequired && !argDef.Required {
|
||||
argDefIndex++
|
||||
argDef = getArgDef(argDefIndex, argDefs)
|
||||
}
|
||||
if argDef.Required {
|
||||
numRequired--
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user