-
-
Notifications
You must be signed in to change notification settings - Fork 75
Update to clap 4.0
#357
Update to clap 4.0
#357
Conversation
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.
Opinion:
I think it was a bit clearer (for the eye) with flags (no args) and options (with args).
Also it is not in alphabetic order anymore, so one need a few moments of looking up and down...
src/cli.rs
Outdated
list_probes: bool, | ||
|
||
/// The chip to program. | ||
#[structopt(long, required_unless_one(&["list-chips", "list-probes", "version"]), env = "PROBE_RUN_CHIP")] | ||
#[arg(long, required = true, conflicts_with_all = HELPER, env = "PROBE_RUN_CHIP")] |
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.
How does that conflicts with help
?
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.
Not at all. It conflicts with --list-chips
, --list_probes
, --version
. It seems I need a better name for HELPER
.
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.
What do you think about HELPER_CMDS
?
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.
Ah ok I see it now when comparing again with structopt
. Those three conflict : list-chips
, list-probes
, version
.
_rest: Vec<String>, | ||
} | ||
|
||
/// Helper commands, which will not execute probe-run normally. |
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.
So you can pass probe-run HELPER
?
I don't get it from the documentation.
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.
No. HELPER
is just a helper variable to not have ["list_chips", "list_probes", "version"]
twice. What could be a better name?
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 think HELPER_CMD
is good! I think I got confused because I expected to see <HELPER_CMD>
, to recognize it immediately as an argument. But that's just me.
I was thinking about that as well. The reasoning of the authors of clap is that they want to give the cli authors (us) control over the order. We can just solve this by alphabetically ordering the args. |
bors r=Dajamante |
Build succeeded: |
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.
Thank you for addressing my questions.
Another quick one: why do we need Cargo.lock
, and can we put <HELPER_CMD>
between arrows, or is it against conventions?
_rest: Vec<String>, | ||
} | ||
|
||
/// Helper commands, which will not execute probe-run normally. |
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 think HELPER_CMD
is good! I think I got confused because I expected to see <HELPER_CMD>
, to recognize it immediately as an argument. But that's just me.
Afaik it is convention to commit the lock file for applications, but not for libraries.
That would be possible. |
This PR updates our cli parser
clap
from2.34
to4.0
.The end-user experience should stay similar, but has a fresh UI, many internal improvements, and better help messages when a user gets the arguments wrong.
On the left you can see the new UI, and on the right the old.
![image](https://user-images.githubusercontent.com/37087391/194344377-e49958f1-412e-45f4-9199-8108d8356368.png)