-
-
Notifications
You must be signed in to change notification settings - Fork 437
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
Avoid using clap deprecated features #787
Merged
zwpaper
merged 25 commits into
lsd-rs:master
from
sudame:fix/avoid-using-clap-deprecated-features
Jan 12, 2023
Merged
Avoid using clap deprecated features #787
zwpaper
merged 25 commits into
lsd-rs:master
from
sudame:fix/avoid-using-clap-deprecated-features
Jan 12, 2023
Conversation
This file contains 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
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. |
@zwpaper if it just about squashing commits, we can do that on Github itself if everything else looks good. |
I had checked the PR and have no questions, thanks so much for this serious PR! @sudame |
Thank you for the prompt response β€οΈπ |
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
->Command
App
is just an alias ofCommand
in this version, so we can replace it.Arg::action
ArgAction::Append
instead ofArg::take_value
ArgAction::SetTrue
for bool flags (likelsd -a
)Arg::validator
->Arg::value_parser
Ok(validated_value)
.Fn(&str) -> Result<T, E>
pattern.)in
flags/*.rs
...Command::get_matches_from_safe
->Command::try_get_matches_from
Command::get_matches_from_safe
is 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::CommandLine
ArgMatches::occurrences_of(id)
returns the number of times an argument was used at runtime, so we can replace it withValueSource::CommandLine
check.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 fmt
Update default config/theme in README (if applicable)Update man page at lsd/doc/lsd.md (if applicable)