From 0d324469860714ee3e397b4d107805f426bd2ac1 Mon Sep 17 00:00:00 2001 From: bth Date: Sun, 18 Jan 2026 18:29:34 -0800 Subject: [PATCH] flags : can check for both Flag types because the value.FieldByName().Type() can be printed --- flags/flags.go | 12 +++++++----- next/next.go | 3 +-- sort/sort.go | 5 +---- tag/tag.go | 5 +---- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/flags/flags.go b/flags/flags.go index 761d63d..f21c8d0 100644 --- a/flags/flags.go +++ b/flags/flags.go @@ -71,14 +71,16 @@ func Help(subcmd string, opts any) { case Arg: positional += fmt.Sprintf(" [%s]", strings.ToLower(field.Name)) fmt.Fprintf(w, "[%v]\tstring\t%v\n", strings.ToLower(field.Name), value.FieldByName("Help")) - case Flag[string]: - positional += fmt.Sprintf(" [%s]", value.FieldByName("Long")) - fmt.Fprintf(w, "%v | %v\tstring\t%v\n", value.FieldByName("Long"), value.FieldByName("Short"), value.FieldByName("Help")) - case Flag[bool]: + case Flag[string], Flag[bool]: if field.Name != "Help" { positional += fmt.Sprintf(" [%s]", value.FieldByName("Long")) } - fmt.Fprintf(w, "%v | %v\tbool\t%v\n", value.FieldByName("Long"), value.FieldByName("Short"), value.FieldByName("Help")) + fmt.Fprintf(w, "%v | %v\t%v\t%v\n", + value.FieldByName("Long"), + value.FieldByName("Short"), + value.FieldByName("Val").Type(), + value.FieldByName("Help"), + ) } } fmt.Printf("um %s%s\n", subcmd, positional) diff --git a/next/next.go b/next/next.go index 8490787..bd7da6d 100644 --- a/next/next.go +++ b/next/next.go @@ -41,6 +41,5 @@ func parseArgs(args []string) options { } func Next(args []string) { - opts := parseArgs(args) - fmt.Println(opts) + _ = parseArgs(args) } diff --git a/sort/sort.go b/sort/sort.go index eb10865..2827656 100644 --- a/sort/sort.go +++ b/sort/sort.go @@ -1,8 +1,6 @@ package sort import ( - "fmt" - "github.com/brtholomy/um/go/flags" ) @@ -45,6 +43,5 @@ func parseArgs(args []string) options { } func Sort(args []string) { - opts := parseArgs(args) - fmt.Println(opts) + _ = parseArgs(args) } diff --git a/tag/tag.go b/tag/tag.go index e37d6a6..f335a09 100644 --- a/tag/tag.go +++ b/tag/tag.go @@ -1,8 +1,6 @@ package tag import ( - "fmt" - "github.com/brtholomy/um/go/flags" ) @@ -45,6 +43,5 @@ func parseArgs(args []string) options { } func Tag(args []string) { - opts := parseArgs(args) - fmt.Println(opts) + _ = parseArgs(args) }