next : keep tags as single flags.Arg : handle comma Split later, ParseArgs does just that
This commit is contained in:
parent
109591f938
commit
519d6cf263
1 changed files with 4 additions and 7 deletions
11
next/next.go
11
next/next.go
|
|
@ -3,20 +3,19 @@ package next
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/brtholomy/um/go/flags"
|
||||
)
|
||||
|
||||
type options struct {
|
||||
descriptor flags.Arg
|
||||
tags []flags.Arg
|
||||
tags flags.Arg
|
||||
}
|
||||
|
||||
func InitOpts() options {
|
||||
return options{
|
||||
flags.Arg{"", "midfix file descriptor"},
|
||||
[]flags.Arg{},
|
||||
flags.Arg{"", "tags to add to new file"},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -25,11 +24,9 @@ func ParseArgs(args []string) options {
|
|||
for i, arg := range args {
|
||||
switch {
|
||||
case i == 0 && !flags.HasDashPrefix(arg):
|
||||
opts.descriptor.Val = args[0]
|
||||
opts.descriptor.Val = arg
|
||||
case i == 1 && !flags.HasDashPrefix(arg):
|
||||
for _, t := range strings.Split(args[1], ",") {
|
||||
opts.tags = append(opts.tags, flags.Arg{t, "tag"})
|
||||
}
|
||||
opts.tags.Val = arg
|
||||
case i >= 2:
|
||||
fmt.Println("um next : too many args")
|
||||
os.Exit(1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue