fix: removes preparsing flag error messages (#1692)

Errors pre-parsing flags to extract --path were incorrectly logging
expected parsing errors when other flags are provided.  Squelched.
This commit is contained in:
Luke Kingland 2023-04-25 22:57:45 +09:00 committed by GitHub
parent 3ac1ef9229
commit e6fa8dddfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -132,10 +132,10 @@ func effectivePath() (path string) {
)
fs.SetOutput(io.Discard)
fs.ParseErrorsWhitelist.UnknownFlags = true // wokeignore:rule=whitelist
err := fs.Parse(os.Args[1:])
if err != nil {
fmt.Fprintf(os.Stderr, "error preparsing flags: %v\n", err)
}
// Preparsing flags intentionally ignores errors because this is intended
// to be an opportunistic parse of the path flags, with actual validation of
// flags taking place later in the instantiation process by the cobra pkg.
_ = fs.Parse(os.Args[1:])
if env != "" {
path = env
}