Prioritize defaultText over value in docs#9
Prioritize defaultText over value in docs#9joshuaswickirl wants to merge 0 commit intourfave:mainfrom
Conversation
| return "" | ||
| } | ||
|
|
||
| if v, ok := f.(interface{ GetValue() string }); ok { |
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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. 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 doesn't exit.
TakesFile: true,
},
...
docs_test.go
Outdated
| &cli.StringFlag{ | ||
| Name: "dir", | ||
| Value: pwd(), | ||
| DefaultText: ".", | ||
| }, |
There was a problem hiding this comment.
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.
docs_test.go
Outdated
| Aliases: []string{"s"}, | ||
| Usage: "some 'usage' text", | ||
| Value: "value", | ||
| DefaultText: "value", |
|
Feel free to reopen this at any point. |
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