diff --git a/.gitignore b/.gitignore index 8a6e397..d3220f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ um +go diff --git a/go b/go deleted file mode 100755 index 7a363ee..0000000 Binary files a/go and /dev/null differ diff --git a/next/next.go b/next/next.go index ef9d2a1..52f109c 100644 --- a/next/next.go +++ b/next/next.go @@ -1,8 +1,45 @@ package next -import "fmt" +import ( + "fmt" + "os" + "strings" + + "github.com/brtholomy/um/go/flags" +) + +type options struct { + descriptor flags.Arg + tags []flags.Arg +} + +func InitOpts() options { + return options{ + flags.Arg{"", "midfix file descriptor"}, + []flags.Arg{}, + } +} + +func ParseArgs(args []string) options { + opts := InitOpts() + for i, arg := range args { + switch { + case i == 0 && !flags.HasDashPrefix(arg): + opts.descriptor.Val = args[0] + case i == 1 && !flags.HasDashPrefix(arg): + for _, t := range strings.Split(args[1], ",") { + opts.tags = append(opts.tags, flags.Arg{t, "tag"}) + } + case i >= 2: + fmt.Println("um next : too many args") + os.Exit(1) + } + } + return opts +} func Next(args []string) { fmt.Println("next") - fmt.Println(args) + opts := ParseArgs(args) + fmt.Println(opts) } diff --git a/tag/tag.go b/tag/tag.go index 231956c..db7413f 100644 --- a/tag/tag.go +++ b/tag/tag.go @@ -46,5 +46,5 @@ func ParseArgs(args []string) options { func Tag(args []string) { fmt.Printf("args: %#v\n", args) opts := ParseArgs(args) - fmt.Printf("opts: %#v\n", opts) + fmt.Println(opts) }