tag : skip value arg in parseArgs
This commit is contained in:
parent
ba46937c3c
commit
c719dc934f
1 changed files with 3 additions and 2 deletions
|
|
@ -24,16 +24,17 @@ func initOpts() options {
|
||||||
|
|
||||||
func parseArgs(args []string) options {
|
func parseArgs(args []string) options {
|
||||||
opts := initOpts()
|
opts := initOpts()
|
||||||
for i, arg := range args {
|
for i := 0; i < len(args); i++ {
|
||||||
|
arg := args[i]
|
||||||
switch {
|
switch {
|
||||||
case i == 0 && !flags.HasDashPrefix(arg):
|
case i == 0 && !flags.HasDashPrefix(arg):
|
||||||
opts.Query.Val = arg
|
opts.Query.Val = arg
|
||||||
case arg == opts.Invert.Long || arg == opts.Invert.Short:
|
case arg == opts.Invert.Long || arg == opts.Invert.Short:
|
||||||
opts.Invert.Val = true
|
opts.Invert.Val = true
|
||||||
case arg == opts.Date.Long || arg == opts.Date.Short:
|
case arg == opts.Date.Long || arg == opts.Date.Short:
|
||||||
// TODO: should we use reflection here for a general Valid(arg, opts.Field)?
|
|
||||||
flags.ValidValueOrExit(args, i)
|
flags.ValidValueOrExit(args, i)
|
||||||
opts.Date.Val = args[i+1]
|
opts.Date.Val = args[i+1]
|
||||||
|
i++
|
||||||
case arg == opts.Help.Long || arg == opts.Help.Short:
|
case arg == opts.Help.Long || arg == opts.Help.Short:
|
||||||
flags.Help("tag", opts)
|
flags.Help("tag", opts)
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue