Support POSIX-style short flag combining
This commit is contained in:
parent
44cb242eeb
commit
43c8c02cf5
14
command.go
14
command.go
@ -142,7 +142,19 @@ func (c Command) Run(ctx *Context) (err error) {
|
|||||||
flagArgs = args[firstFlagIndex:]
|
flagArgs = args[firstFlagIndex:]
|
||||||
}
|
}
|
||||||
|
|
||||||
err = set.Parse(append(flagArgs, regularArgs...))
|
// separate combined flags
|
||||||
|
var flagArgsSeparated []string
|
||||||
|
for _, flagArg := range flagArgs {
|
||||||
|
if strings.HasPrefix(flagArg, "-") && strings.HasPrefix(flagArg, "--") == false && len(flagArg) >2 {
|
||||||
|
for _, flagChar := range flagArg[1:] {
|
||||||
|
flagArgsSeparated = append(flagArgsSeparated, "-" + string(flagChar))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
flagArgsSeparated = append(flagArgsSeparated, flagArg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = set.Parse(append(flagArgsSeparated, regularArgs...))
|
||||||
} else {
|
} else {
|
||||||
err = set.Parse(ctx.Args().Tail())
|
err = set.Parse(ctx.Args().Tail())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user