Skip to content

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

Open
johnSchnake wants to merge 1 commit into
spf13:masterfrom
johnSchnake:noGoEscape
Open

Prevent help output from escaping default values as go strings#347
johnSchnake wants to merge 1 commit into
spf13:masterfrom
johnSchnake:noGoEscape

Conversation

@johnSchnake
Copy link
Copy Markdown

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>
Comment thread flag.go
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
Copy Markdown
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.

Comment thread flag.go
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
Copy Markdown
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