while print flag , the placeholder if need but not set.#2043
Conversation
|
@Skeeve Thank you, could you please take a look |
I can, but I cannot approve. |
|
It's currently possible to get the following help output with the I think either one of those cases could be changed to overwrite the placeholder without setting a usage. |
|
I didn't know this was a workaround to get stdlib flag functionality. Might I add two points to consider:
|
|
Thanks all @avorima @abitrolly @Skeeve . I will make a summary based on your suggestions and explain my ideas ,
my next step will be:
|
That's a nice idea , May I consider it . From the current perspective, using reflection should be sufficient. |
e922a04 to
166beb6
Compare
print flag type first. Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
|
0cb6639#diff-f09230a06a76ff761bbdcc9b788aa057cc5caa463f1bd68e67b14422938622d4R110 I think the "[]" is of no additional value and should be omitted.
I think you should avoid the "[]" marker. |
That's for these type like UintSliceFlag's flag can print '[]uint64' and reflect.Type.Name() can't return the slice type . Or may I print like this 'uint64s' for different from 'uint64' type? |
Why would you want to distinguish a uint64 from a slice of uint64. It transfers no additional meaning to the reader. If a flag is a slice flag, the only difference in usage is, that you can use the flag several times. This is usually stated in the usage text. |
You're right. How about just print the slice type ? => --greeting string [ --greeting string ] Pass multiple greetings |
|
Actually, the placeholder hack is documented https://cli.urfave.org/v3/examples/flags/#placeholder-values Maybe it doesn't need to be overcomplicated. Maybe stub basic types and provide an extension to explicitly format placeholder name for other things. |
Sorry, I didn't understand. Can you be more detailed. If it means do not use reflection , Do you directly give the name of the flag type when initializing the flag? |
deparcated the slice type prefix'[]' Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
|
@Skeeve I've changed in new commit , may be it looks greater. |
dearchap
left a comment
There was a problem hiding this comment.
Thanks for the PR @jokemanfire
c6b26b8 to
9015c2f
Compare
avorima
left a comment
There was a problem hiding this comment.
Some observations regarding the type names
|
@Scutua say something. |
0baf377 to
8682140
Compare
If flag is StringMapFlag ,it will print `--property string=string [--property string=string]…` Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
What type of PR is this?
What this PR does / why we need it:
Change like this:
OPTIONS:
--bar value
--help, -h show help
OPTIONS:
--bar string
--help, -h show help
Special notes for your reviewer:
This is a feature that I like because having a placeholder as a value is not very helpful for users. And it's a bit troublesome to specifically set up a placeholder.
Testing
I have run the help_test.go , but it can't pass . Because I consider if we should add a switch, otherwise it will affect the compatibility of the previous version
Release Notes
Change flag show placeholder to show flag initial type.