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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/brtholomy/um/go/flags"
|
"github.com/brtholomy/um/go/flags"
|
||||||
)
|
)
|
||||||
|
|
||||||
type options struct {
|
type options struct {
|
||||||
descriptor flags.Arg
|
descriptor flags.Arg
|
||||||
tags []flags.Arg
|
tags flags.Arg
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitOpts() options {
|
func InitOpts() options {
|
||||||
return options{
|
return options{
|
||||||
flags.Arg{"", "midfix file descriptor"},
|
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 {
|
for i, arg := range args {
|
||||||
switch {
|
switch {
|
||||||
case i == 0 && !flags.HasDashPrefix(arg):
|
case i == 0 && !flags.HasDashPrefix(arg):
|
||||||
opts.descriptor.Val = args[0]
|
opts.descriptor.Val = arg
|
||||||
case i == 1 && !flags.HasDashPrefix(arg):
|
case i == 1 && !flags.HasDashPrefix(arg):
|
||||||
for _, t := range strings.Split(args[1], ",") {
|
opts.tags.Val = arg
|
||||||
opts.tags = append(opts.tags, flags.Arg{t, "tag"})
|
|
||||||
}
|
|
||||||
case i >= 2:
|
case i >= 2:
|
||||||
fmt.Println("um next : too many args")
|
fmt.Println("um next : too many args")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue