Skip to content
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

Bump Rust edition, use caret requirements, upgrade to clap 4 #104

Merged
merged 3 commits into from
Mar 23, 2024

Conversation

Pi-Cla
Copy link

@Pi-Cla Pi-Cla commented Mar 22, 2024

Running cargo msrv revealed that the minimum Rust version of this crate is already 1.64.0 so bumping the Rust edition does not effect the minimum. Also caret requirements are looser than tilde but still semver compatible so it should be good to switch (when a version is just like "2.33" cargo defaults to caret requirements)

I have also decided to migrate the crate to clap 4 because clap 2 and 3 depend on an unmaintained crate with a potential security vulnerability https://rustsec.org/advisories/RUSTSEC-2021-0145

I placed the details on the migration to clap 4 in the corresponding commit message

I have ran both cargo build and cargo test and everything still works

However, the migration to the latest version of clap 4 does raise the msrv to 1.74.1
Alternatively clap and clap_complete could be pinned at version 4.2.1 to instead only have an msrv increase to 1.67.1.
Since they bumped their internal dependencies in 4.2.2

Feel free to ask any questions about this PR


Migration guide to clap 3
Migration guide to clap 4

Pi-Cla added 2 commits March 22, 2024 13:03
I ran `cargo msrv` and the minimum version of this crate
was 1.64.0 so bumping the Rust edition does not raise the minimum
@Pi-Cla Pi-Cla changed the title Bump Rust edition and use caret requirements Bump Rust edition, use caret requirements, upgrade to clap 4 Mar 22, 2024
I did this because clap 2 and 3 has a dependency on
atty which is unmaintained and has a potential security
vulnerability https://rustsec.org/advisories/RUSTSEC-2021-0145

clap 4 migration details:
- Arg::with_name() has been replaced with Arg::new()
- possible_values has been replaced with value_parser
- args.value_of has been replaced with args.get_one::<String>
- args.gen_completions_to() has been replaced with generate()
- The way we use args.is_present() means it is replaced with
  contains_id()
- Shell completion has been moved to the clap_complete crate

- app_from_crate! has been replaced with command!
  * Which now requires a the `cargo` feature flag to access

- line wrapping is now behind a feature flag `wrap_help`
  * Migration guide recommends we enable this or else
    we would need to manually implement line wrapping

- Args are now assumed to take values by default
  so in order to specify a flag
  we need to append .action(ArgAction::SetTrue) to each arg.
  * takes_value() has been removed
@tummychow tummychow merged commit 6997063 into tummychow:master Mar 23, 2024
3 checks passed
@Pi-Cla Pi-Cla deleted the edition-2021 branch March 24, 2024 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants