From e55b361498fd8d1c697984e095d017fdb679b60d Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Thu, 2 May 2019 09:50:44 -0700 Subject: [PATCH] fix error message --- parse.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parse.go b/parse.go index 0633bb6..d4a6334 100644 --- a/parse.go +++ b/parse.go @@ -21,6 +21,9 @@ type path struct { // String gets a string representation of the given path func (p path) String() string { + if len(p.fields) == 0 { + return "args" + } return "args." + strings.Join(p.fields, ".") } @@ -330,7 +333,7 @@ func cmdFromStruct(name string, dest path, t reflect.Type) (*command, error) { } } if hasPositional && len(cmd.subcommands) > 0 { - return nil, fmt.Errorf("%T cannot have both subcommands and positional arguments", t) + return nil, fmt.Errorf("%s cannot have both subcommands and positional arguments", dest) } return &cmd, nil