Don't show ... in help for named slice types.

This commit is contained in:
Alec Thomas
2018-11-06 11:15:35 +11:00
parent 041e879d63
commit e474873f84
2 changed files with 16 additions and 1 deletions
+15
View File
@@ -1,6 +1,7 @@
package kong_test
import (
"bytes"
"fmt"
"io/ioutil"
"net/url"
@@ -166,3 +167,17 @@ func TestFileContentFlag(t *testing.T) {
require.NoError(t, err)
require.Equal(t, []byte("hello world"), []byte(cli.File))
}
func TestNamedSliceTypesDontHaveEllipsis(t *testing.T) {
var cli struct {
File kong.FileContentFlag
}
b := bytes.NewBuffer(nil)
parser := mustNew(t, &cli, kong.Writers(b, b), kong.Exit(func(int) { panic("exit") }))
// Ensure that --help
require.Panics(t, func() {
_, err := parser.Parse([]string{"--help"})
require.NoError(t, err)
})
require.NotContains(t, b.String(), `--file=FILE-CONTENT-FLAG,...`)
}
+1 -1
View File
@@ -251,7 +251,7 @@ func (v *Value) IsCumulative() bool {
// IsSlice returns true if the value is a slice.
func (v *Value) IsSlice() bool {
return v.Target.Kind() == reflect.Slice
return v.Target.Type().Name() == "" && v.Target.Kind() == reflect.Slice
}
// IsMap returns true if the value is a map.