Skip to content
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

Prevent help output from escaping default values as go strings #347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnSchnake
Copy link

When creating the help text for a flag, the default value shouldn't be
be excaped. It isn't clear to an end user that we would be escaping those values.

Instead we should be printing the actual value and letting the users decide
when/how to add escaping based on how they're utilzing it.

Fixes #346

Signed-off-by: John Schnake jschnake@vmware.com

When creating the help text for a flag, the default value shouldn't be
be excaped. It isn't clear to an end user that we would be escaping those values.

Instead we should be printing the actual value and letting the users decide
when/how to add escaping based on how they're utilzing it.

Fixes spf13#346

Signed-off-by: John Schnake <jschnake@vmware.com>
@@ -475,7 +475,7 @@ func (f *FlagSet) Set(name, value string) error {
} else {
flagName = fmt.Sprintf("--%s", flag.Name)
}
return fmt.Errorf("invalid argument %q for %q flag: %v", value, flagName, err)
return fmt.Errorf(`invalid argument "%v" for "%v" flag: %v`, value, flagName, err)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preempting a similar issue here potentially.

@@ -411,7 +411,7 @@ func (f *FlagSet) ArgsLenAtDash() int {
func (f *FlagSet) MarkDeprecated(name string, usageMessage string) error {
flag := f.Lookup(name)
if flag == nil {
return fmt.Errorf("flag %q does not exist", name)
return fmt.Errorf(`flag "%v" does not exist`, name)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preempting a similar issue here potentially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default strings in help shouldn't be Go escaped
1 participant