mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
Only delete arg when it is not starts with -
Signed-off-by: JaySon-Huang <tshent@qq.com>
This commit is contained in:
parent
a916286db1
commit
d364ed0157
1 changed files with 4 additions and 3 deletions
|
@ -585,11 +585,12 @@ Loop:
|
||||||
case strings.HasPrefix(s, "-") && !strings.Contains(s, "=") && len(s) == 2 && !shortHasNoOptDefVal(s[1:], flags):
|
case strings.HasPrefix(s, "-") && !strings.Contains(s, "=") && len(s) == 2 && !shortHasNoOptDefVal(s[1:], flags):
|
||||||
// If '-f arg' then
|
// If '-f arg' then
|
||||||
// delete 'arg' from args or break the loop if len(args) <= 1.
|
// delete 'arg' from args or break the loop if len(args) <= 1.
|
||||||
if len(args) <= 1 {
|
if len(args) == 0 {
|
||||||
break Loop
|
break Loop
|
||||||
} else {
|
}
|
||||||
|
// Only delete 'arg' when it is not starts with '-'
|
||||||
|
if !strings.HasPrefix(args[0], "-") {
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
case s != "" && !strings.HasPrefix(s, "-"):
|
case s != "" && !strings.HasPrefix(s, "-"):
|
||||||
commands = append(commands, s)
|
commands = append(commands, s)
|
||||||
|
|
Loading…
Reference in a new issue