mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
commands/cli: Fixed parse bug when optional argument is defined first
This commit is contained in:
parent
cefb0140cb
commit
a69ddbb965
@ -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--
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user