-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
while print flag , the placeholder if need but not set. #2043
base: main
Are you sure you want to change the base?
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. |
This whole section is questionable. Lines 300 to 310 in 7fc43e7
The |
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 <[email protected]>
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. |
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.