-
Notifications
You must be signed in to change notification settings - Fork 4
Prioritize defaultText over value in docs #9
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
base: main
Are you sure you want to change the base?
Conversation
test default ran into a different bug so im avoiding that
@@ -565,21 +565,19 @@ func getFlagDefaultValue(f cli.DocGenerationFlag) string { | |||
return "" | |||
} | |||
|
|||
if v, ok := f.(interface{ GetValue() string }); ok { |
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.
@joshuaswickirl i'm having a hard time wrapping my head around this. You say that DocGenerationFlag has removed GetValue ?? It's still there. So I'm confused why we need all this in the first place. Moreover there is no need to use reflection here. You should be able to use be existing functions to achieve the desired result
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.
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.
Hi, thanks for your response.
I went to use the DocGenerationFlag.GetDefaultText
but the response is different between Value
and DefaultText
. The string response for value is unquoted and for default text is unquoted. I'd assume that you would want the behavior to be the same between Value
and DefaultText
, if the value is the exact same string.
It seems like the interface implementation is inconsistent but I haven't confirmed.
I'll push up the current state. Again, I appreciate your time.
func buildExtendedTestCommand() *cli.Command {
return &cli.Command{
Writer: io.Discard,
Name: "greet",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "socket",
Aliases: []string{"s"},
Usage: "some 'usage' text",
Value: "value",
// DefaultText: "value", <-- tests fail if this doesnt exit.
TakesFile: true,
},
...
&cli.StringFlag{ | ||
Name: "dir", | ||
Value: pwd(), | ||
DefaultText: ".", | ||
}, |
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.
I'd like to be able to overwrite the default value with default text. In my example here the pwd()
is called at build so it'd show my actual $PWD
and that wouldn't make sense in the docs.
Aliases: []string{"s"}, | ||
Usage: "some 'usage' text", | ||
Value: "value", | ||
DefaultText: "value", |
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.
In cases where the default value is dynamic or programmatic, it'd be nice to be able to align the docs with the help text.
https://cli.urfave.org/v3/examples/flags/advanced/#default-values-for-help-output