Avoid using clap deprecated features#787
Merged
zwpaper merged 25 commits intoJan 12, 2023
Merged
Conversation
Member
|
Thanks so much for this detailed PR @sudame! there is one more thing that may need you to do, there are too many tiny commits, please squash your commits. |
Member
|
@zwpaper if it just about squashing commits, we can do that on Github itself if everything else looks good. |
Member
|
I had checked the PR and have no questions, thanks so much for this serious PR! @sudame |
Contributor
Author
|
Thank you for the prompt response ❤️🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PR will fix #786 .
💪 Motivation
In order to minimize future security risks and maintain ease of use, it is recommended to avoid using deprecated features of clap.
✅ What I did
I have refactored the code so that no warning appears when the following command is executed:
This command was introduced for migration to v4, but we can use it here.
🔄 Main Changes
also see 👀 : https://github.com/clap-rs/clap/blob/master/CHANGELOG.md
in
app.rs...App->CommandAppis just an alias ofCommandin this version, so we can replace it.Arg::actionArgAction::Appendinstead ofArg::take_valueArgAction::SetTruefor bool flags (likelsd -a)Arg::validator->Arg::value_parserOk(validated_value).Fn(&str) -> Result<T, E>pattern.)in
flags/*.rs...Command::get_matches_from_safe->Command::try_get_matches_fromCommand::get_matches_from_safeis just an alias ofCommand::try_get_matches_from, so we can replace it.ArgMatches::is_present->ArgMatches::get_one::<bool>ArgMatches::occurrences_of(id) > 0->ArgMatches::value_source(id) == ValueSource::CommandLineArgMatches::occurrences_of(id)returns the number of times an argument was used at runtime, so we can replace it withValueSource::CommandLinecheck.ArgMatches::values_of->ArgMatches::get_many::<T>ArgMatches::value_of->ArgMatches::get_one::<T>ArgMatches::get_*::<String>and thenmap(String::as_str)to conform to existing codes which uses&str.💭 Comments
TODO
cargo fmtUpdate default config/theme in README (if applicable)Update man page at lsd/doc/lsd.md (if applicable)