Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Update to clap 4.0 #357

Merged
merged 7 commits into from
Oct 6, 2022
Merged

Update to clap 4.0 #357

merged 7 commits into from
Oct 6, 2022

Conversation

Urhengulas
Copy link
Member

@Urhengulas Urhengulas commented Oct 6, 2022

This PR updates our cli parser clap from 2.34 to 4.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

@Urhengulas Urhengulas requested review from Dajamante and removed request for jonas-schievink October 6, 2022 10:56
Copy link

@Dajamante Dajamante left a 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")]

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?

Copy link
Member Author

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.

Copy link
Member Author

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?

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.

src/cli.rs Outdated Show resolved Hide resolved
_rest: Vec<String>,
}

/// Helper commands, which will not execute probe-run normally.

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.

Copy link
Member Author

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?

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.

src/cli.rs Outdated Show resolved Hide resolved
src/cli.rs Show resolved Hide resolved
@Urhengulas
Copy link
Member Author

Also it is not in alphabetic order anymore, so one need a few moments of looking up and down...

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.

@Urhengulas Urhengulas requested a review from Dajamante October 6, 2022 14:51
@Urhengulas
Copy link
Member Author

bors r=Dajamante

@bors
Copy link
Contributor

bors bot commented Oct 6, 2022

Build succeeded:

@bors bors bot merged commit 69fd4bf into main Oct 6, 2022
@bors bors bot deleted the clap-4 branch October 6, 2022 15:04
Copy link

@Dajamante Dajamante left a 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.

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.

@Urhengulas
Copy link
Member Author

why do we need Cargo.lock?

Afaik it is convention to commit the lock file for applications, but not for libraries.

can we put <HELPER_CMD> between arrows, or is it against conventions?

That would be possible.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants