CLI: Fix erroneous warning when reading from stdin (#17252)

This commit is contained in:
Tom Proctor
2022-09-21 21:04:49 +01:00
committed by GitHub
parent 0b34b73c47
commit 6fc78315f7
2 changed files with 6 additions and 1 deletions

View File

@@ -296,7 +296,8 @@ func parseFlagFile(raw string) (string, error) {
func generateFlagWarnings(args []string) string {
var trailingFlags []string
for _, arg := range args {
if !strings.HasPrefix(arg, "-") {
// "-" can be used where a file is expected to denote stdin.
if !strings.HasPrefix(arg, "-") || arg == "-" {
continue
}

View File

@@ -262,6 +262,10 @@ func TestArgWarnings(t *testing.T) {
[]string{"--x=" + globalFlagDetailed},
"--x=" + globalFlagDetailed,
},
{
[]string{"policy", "write", "my-policy", "-"},
"",
},
}
for _, tc := range cases {