diff --git a/help_test.go b/help_test.go index 7d0a6ddef753ef28f3b960e7bf910d9f8b1d03b6..8508a5cce81ba8e83c3554ee8b35331fb6f76f36 100644 --- a/help_test.go +++ b/help_test.go @@ -32,9 +32,9 @@ func TestGetHelp(t *testing.T) { args []string substring string }{ - {"test1", []string{"sub1", "--help"}, "Usage: test1 sub1 [global options] [command] [arguments]"}, - {"test1", []string{"xsd", "help"}, "Usage: test1 [global options] [command] [arguments]"}, - {"test2", []string{"sub1", "sub2"}, "Usage: test2 sub1 sub2 [global options] [command] [arguments]"}, + {"test1", []string{"sub1", "--help"}, "Usage: [global options] [command] [arguments]\n\nGlobal Options:\n -a\tMessage A\n -x int\n \tMessage X\n\nCommand: sub1\n\nOptions:\n -b\tMessage B\n"}, + {"test1", []string{"xsd", "help"}, "Usage: [global options] [command] [arguments]\n\nGlobal Options:\n -a\tMessage A\n -x int\n \tMessage X\n\nCommand: sub1\n\nOptions:\n -b\tMessage B\n"}, + {"test2", []string{"sub1", "sub2"}, "Usage: [global options] [command] [arguments]\n\nGlobal Options:\n -a\tMessage A\n -x int\n \tMessage X\n\nCommand: sub1\n\nOptions:\n -b\tMessage B\n"}, } for _, table := range tables { diff --git a/mapping.go b/mapping.go index 296973d2433d024a29db5a656758dbb7fa0a8cd8..19a0b66771c6c7947fc10bb2dcc5dc980a2fa7bd 100644 --- a/mapping.go +++ b/mapping.go @@ -37,7 +37,7 @@ func (s *Settings[C]) assignValues(c cmd[C]) { flgs.Visit(func(f *flag.Flag) { name := f.Name - value := f.Value //.String() + value := f.Value.String() k, ok := c.tagMapping[name] if !ok { diff --git a/type.go b/type.go index 48172c48ba447139f3ba2514ebfaab704f6bc2ad..c03332a70eb403daeccdd42cbe32141d6a915dae 100644 --- a/type.go +++ b/type.go @@ -1,6 +1,9 @@ package xflags -import "strings" +import ( + "fmt" + "strings" +) type StringFlags []string @@ -18,7 +21,7 @@ type IntFlags []int func (i *IntFlags) String() string { r := make([]string, len(*i)) for k, v := range *i { - r[k] = string(v) + r[k] = fmt.Sprintf("%c", v) } return strings.Join(r, ",")