-
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
What's the best practice to report an error when using a bool flag in the wrong way? #2057
Comments
Maybe you should provide more info? I, for my part, have no clue what |
The AttackFlag = &cli.BoolFlag{
Name: "attack",
Usage: "An attack move. If true, the defend flag must not be set.",
} |
That's not sufficient. You should provide the full cli definition. OTOH: So when you check your arguments, you will have So maybe check you arguments for anything which looks like a flag? |
The full definition is here but as I said it's irrelevant.
Yeah that's correct, but my question is about how to automatically remind the user that he/she has specified |
The user did not specify So there is no automated way to achieve what you ask for. It's your task to inform the user. Any program I would write would happily accept the The next parameter Just a hint: you're using |
I can understand there's no way to reliably detect it 100%. But if there's a |
So go ahead, switch to OTOH: I do not think this is very useful, because you will be unable to use e.g. the filename |
It's a big project not owned by me:) I just met this issue while using it lol.
We can always improve the auto-detection during iterations. |
So if it's not your project, what's the reason for asking for improvements in
Who is "we"? If "we" includes "you", go ahead and create a PR for this auto-detection in |
Because I see it as a general issue when using cli flags. I don't have the bandwidth to do a PR now, but may do it in the future. |
The
--attack
is a bool flag, but when run as:./bin/op-challenger move -attack 1 --claim 0xffff --private-key $PK
--attack 1
makes the remaining parameters empty(e.g.,--private-key
will be interpreted as empty), which will cause confusion to users.What's the best way to notify user that the
1
behind--attack
is unnecessary and will cause trouble in this situation?The text was updated successfully, but these errors were encountered: