next : keep tags as single flags.Arg : handle comma Split later, ParseArgs does just that

This commit is contained in:
bth 2026-01-18 10:21:01 -08:00
commit 519d6cf263

View file

@ -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)