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 2c8e88ab67
commit b0a580de47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {