-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
Upgrade to clap 4 #5405
Upgrade to clap 4 #5405
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.
Looks great overall. Just a few minor comments.
crates/cli/src/lib.rs
Outdated
.required(false); | ||
|
||
let flag_prebuilt = Arg::new(FLAG_PREBUILT) | ||
.long(FLAG_PREBUILT) | ||
.help("Assume the platform has been prebuilt and skip rebuilding the platform\n(This is enabled by default when using `roc build` with a --target other than `--target <current machine>`.)") | ||
.possible_values(["true", "false"]) | ||
.value_parser(["true", "false"]) |
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.
While we are here, can we flip this to use .action(ArgAction::SetTrue)
instead of true
and false
?
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.
Is it ok that it's not backward compatible? If so, happy to make the change.
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 see the current implementation also allows you to opt out of the default behavior defined here, which we'd lose by switching to a bool.
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.
Ultimately, this flag will go away. So exactly how it works doesn't matter too much.
I think it should be fine to just make the inside of the first branch be true and the second branch stay the same. If that makes sense.
But no big deal either way, so feel free to not fix.
crates/cli/src/lib.rs
Outdated
.help("The package's main .roc file") | ||
.allow_invalid_utf8(true) | ||
.num_args(0..0) |
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.
0 to 0 ?
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... do not know how that got there. Thanks for catching it.
crates/cli/src/lib.rs
Outdated
Arg::new(FLAG_TARGET) | ||
.long(FLAG_TARGET) | ||
.help("Choose a different target") | ||
.default_value(Target::default().into()) | ||
.possible_values(Target::iter().map(|target| { | ||
Into::<&'static str>::into(target) | ||
})) | ||
.default_value(Into::<&'static str>::into(Target::default())) | ||
.value_parser( | ||
PossibleValuesParser::new( | ||
Target::iter().map(|target| { | ||
Into::<&'static str>::into(target) | ||
}) | ||
)) | ||
.required(false), |
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.
Given this is a bit complex, can we define it as a variable at the top and share it between all uses?
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.
Done
Yeah, should be fine. We already talked about making this change anyway.
May require changing use in a test, but should be fine to do that as well.
…On Sun, May 14, 2023, 4:31 PM David Smith ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In crates/cli/src/lib.rs
<#5405 (comment)>:
> .required(false);
let flag_prebuilt = Arg::new(FLAG_PREBUILT)
.long(FLAG_PREBUILT)
.help("Assume the platform has been prebuilt and skip rebuilding the platform\n(This is enabled by default when using `roc build` with a --target other than `--target <current machine>`.)")
- .possible_values(["true", "false"])
+ .value_parser(["true", "false"])
Is it ok that it's not backward compatible? If so, happy to make the
change.
—
Reply to this email directly, view it on GitHub
<#5405 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB7S22FZ2LTPOLALGQNKHWDXGFTM5ANCNFSM6AAAAAAYATAUVE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Looks great! Thanks for dealing with this update. |
- Remove `num_args` call that wasn't supposed to be there - Factor out shared value parser with non-trivial init
With this change, it's no longer possible to cross-compile to any target other than wasm.
Head branch was pushed to by a user without write access
I think you may need to search for For comments/strings, just change uses of |
I think confy dependencies changes, so the sha needs to be updated Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
@@ -23,7 +23,7 @@ rustPlatform.buildRustPackage { | |||
cargoLock = { | |||
lockFile = ./Cargo.lock; | |||
outputHashes = { | |||
"confy-0.5.1" = "sha256-3PQdz9W/uJd4CaUZdwAd2u3JJ100SFAoKLCFE6THRZI="; | |||
"confy-0.5.1" = "sha256-KML/uoze2djsFhYk488QAtauethDaC+0aZ3q56yAhuY="; |
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.
General question: how does the sha change without changing the version?
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 was wondering the same thing for a while. The sha is for the built result, not for the confy source. With this PR the changing of dependencies led to some changes in dependency resolution and serde was changed to 1.0.163, serde is a dependency for confy, so confy was changed.
I'll look at the clippy failure |
Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
Thanks for the help, @Anton-4! |
Fixes omission in the [clap v4 upgrade](roc-lang#5405) See [relevant bullet](https://github.com/clap-rs/clap/blob/2d4644a8703369d3a3c50dd58c713d48ab1da2ac/CHANGELOG.md?plain=1#LL590C32-L590C67) in changelog.
Issue #5388
Summary of changes
Arg.num_args
multiple_values
andtakes_value
Arg.value_parser
Arg.possible_values
Arg.allow_invalid_utf8
, either parsing directly toPathBuf
orOsString
usize
)ArgMatches.get_one
andArgMatches.get_many
in place ofArgMatches.value_of*
andArgMatches.values_of*
Arg.action(ArgAction::SetTrue)
for flagsArgMatches.is_present
withArgMatches.get_flag
for flagsArgMatches.is_present
withArgMatches.contains_id
to check option presenceApp.trailing_var_arg
Arg
and now conflicts withlast
. See relevant unit test.