Don't show ... in help for named slice types.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package kong_test
|
package kong_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -166,3 +167,17 @@ func TestFileContentFlag(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, []byte("hello world"), []byte(cli.File))
|
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,...`)
|
||||||
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ func (v *Value) IsCumulative() bool {
|
|||||||
|
|
||||||
// IsSlice returns true if the value is a slice.
|
// IsSlice returns true if the value is a slice.
|
||||||
func (v *Value) IsSlice() bool {
|
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.
|
// IsMap returns true if the value is a map.
|
||||||
|
|||||||
Reference in New Issue
Block a user