Allow merge bool v2#2137
Conversation
…ing a PR" This reverts commit f8cf080.
@katrinafyi @mre What are your thoughts? |
katrinafyi
left a comment
There was a problem hiding this comment.
Yeah I agree with @thomas-zahner on the discussion points.
The PR looks reasonable, it's basically exactly what I expected for this change. Somewhat large, but fairly rote.
Thanks for tackling it!
|
Thanks @katrinafyi and @thomas-zahner for your feedback. I believe I addressed all your comments. PTAL. |
|
Re the big
If you want, it's worth a try @cristiklein. The idea is that the So, if you add an extension method on pub trait ArgExt {
fn optional_with_bool_value(self) -> Arg {
// apply the needed options using the builder API
}
}
// then later,
#[arg(optional_with_bool_value)] |
e5126ac to
5931004
Compare
|
Great find @katrinafyi and works like a charm. See 2521d07. Help message didn't change at all during refactoring. @mre I found a few ways to beautify the help message. For example: Leads to: See 5931004 |
|
Arrrgggh, sorry, I pressed ENTER too fast. So the best I could obtain was: Which leads to: |
Incredible! Honestly I had no idea if it would work. Thanks for doing that, I think it's a bit cleaner :) |
|
@cristiklein @katrinafyi Thank you, that's quite a lot less boilerplate code and quite an improvement! |
|
Love it! Thanks for catching that the test was slow.
…On Tue, Apr 14, 2026, 17:43 Thomas Zahner ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lychee-bin/tests/cli.rs
<#2137 (comment)>:
> @@ -4123,6 +3899,22 @@ https://lychee.cli.rs/guides/cli/#fragments-ignored
.stdout(contains("resource-1.md").count(2));
}
+ #[tokio::test]
+ async fn test_set_bool_to_false() {
@cristiklein <https://github.com/cristiklein> Are you okay with c9bbc4f
<c9bbc4f>
?
Alternatively I'm okay with reverting the commit and fully removing the
test_set_bool_to_false test. I think both tests are not hugely important.
—
Reply to this email directly, view it on GitHub
<#2137 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMVPILUTJMF5BCEVAQD54T4VZMBRAVCNFSM6AAAAACXVD3ETCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHM2DCMBXGI4DIOBUG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
c9bbc4f to
7903a99
Compare
Fixes #2051
Makes all boolean CLI flags mergeable by converting them to
Option<bool>. For example, this allowslychee.tomlto specifyaccept_timeout = trueand callinglychee --accept-timeout=falsewith the combined effect being that timeouts are not accepted.This PR uses the following overall patterns:
Option<bool>.config/mod.rs.Decisions to be challenged:
#[arg(...)]macro invokation looks tedious and repetative. I opted against factoring this into a macro, since the solution felt beyond my ability.Option<bool>, even e.g.--dump? I opted for this, since I felt this minimizes astonishment for the user.--no-flag, like ripgrep? This feels poorly supported in Clap. Furthermore, many CLI seems to move towards--flag=false.