-
-
Notifications
You must be signed in to change notification settings - Fork 180
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
Migrate clap to version 4 with derives #1359
Conversation
I think this is the least changes I could possibly do. |
One test does not pass after the refactor: let args = TarpaulinCli::parse_from(vec![
"tarpaulin",
"--exclude-files",
"src/foo/*",
// No `--exclude-files` before the next argument
"src\\bar\\*",
]); |
I wanna just ignore it and add the missing |
in clap 3 I think |
I'll check again, it could be one of those builder-only things |
Yeah, so it exists in clap 3 and disappears in clap 4, either they renamed it or it's totally gone |
I found it, extremely obscure and undocumented, even in the source code I couldn't find it: I'll patch it in a second, just wanna write an issue on |
The next step would be to separate arguments for building tests, running tests and processing results. |
Oh yeah, about the convention of multiple values per flag, |
Should I work on the next changes in this PR or a new one? |
A new one please, I'm trying to find some time to review this one as it is (part way through it). And when that's done I'll merge it in. More changes come in it'll slow down the review a bit 😅 |
there are some conflicts to resolve though - before merge |
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.
Just a few comments both of which are code formatting. I'll also clone your fork and do a quick sanity check to make sure things look how I expect from a UX perspective
src/args.rs
Outdated
pub struct TarpaulinCli { | ||
#[clap(flatten)] | ||
pub print_flags: PrintFlagsArgs, | ||
|
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.
style nit, I'd prefer the empty lines between fields to be removed. But if this is my only comment on this PR can ignore it
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.
In the long run I'd lean towards this too, it was easier to work with in the 200-line struct but the goal is to make it smaller anyways
Always, | ||
Never, | ||
} | ||
#[derive( |
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.
Did cargo fmt
really do this?
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.
Yup
Okay one regression |
f56b489
to
7dbc313
Compare
Getting closer, it actually shows some printout from tarpaulin not cargo
|
I tried a few thing but nothing worked like it should so I posted a question on clap's discussion forum hopefully I missed something |
Very quick response from the clap team, there are 2 working solutions, I went with the less bloaty one, felt more in line with what I originally tried. |
LGTM thanks for the hard work! Once CI passes I'll merge this in 🚀 |
Motivation:
Current app uses an old version of
clap
crate with the builder convention, which adds a lot of additional runtime uncertainty and makes it difficult to separate the arguments into multiple apps/subcommands. Using the currently available derive convention will make it easier to group arguments together and make use of compile time checks.Changes:
clap
crate to v4