-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a small utility method to display a warnings. #16441
Conversation
Will print warning if flag is passed after arguments e.g. vault <command> -a b -c In this example -c will be interpreted as an argument which may be misleading
command/base.go
Outdated
printArgsWarningIfAny(&out, f.Args()) | ||
if out.String() != "" { | ||
f.ui.Warn(out.String()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you can have printArgsWarningIfAny
return the warning as a string, and output the string if it's non-empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just some small suggestions
* returning string value instead of using output buffer * rephrased warning message for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the recent commits 👍
Will print warning if flag is passed after positional arguments e.g.
vault <command> -a b -c
In this example
-c
will be interpreted as an argument because go-flag stops parsing after the first non-flag arg.This behaviour may cause confusion or commands to run with unexpected results.
The decision to display a warning instead of crashing was to avoid potentially breaking existing scripts and integrations.
Small clean-up:
f