Add NamedFileContentFlag.

This commit is contained in:
Alec Thomas
2020-10-30 15:26:38 +11:00
parent 097bba54ec
commit 8bf0a335db
2 changed files with 41 additions and 0 deletions
+14
View File
@@ -240,6 +240,20 @@ func TestFileContentFlag(t *testing.T) {
require.Equal(t, []byte("hello world"), []byte(cli.File))
}
func TestNamedFileContentFlag(t *testing.T) {
var cli struct {
File kong.NamedFileContentFlag
}
f, err := ioutil.TempFile("", "")
require.NoError(t, err)
defer os.Remove(f.Name())
fmt.Fprint(f, "hello world")
f.Close()
_, err = mustNew(t, &cli).Parse([]string{"--file", f.Name()})
require.NoError(t, err)
require.Equal(t, []byte("hello world"), cli.File.Contents)
}
func TestNamedSliceTypesDontHaveEllipsis(t *testing.T) {
var cli struct {
File kong.FileContentFlag