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

Infer long arguments #2525

Merged
merged 2 commits into from
Jun 6, 2021
Merged

Conversation

tertsdiepraam
Copy link
Contributor

Closes #1786.

This PR add support abbreviated long options, such as writing --test as --t, --te or --test if the argument is ambiguous. It is enabled with AppSettings::InferLongArgs, modeled after AppSettings::InferSubcommands.

Also, thank you for this amazing project!

Copy link
Member

@pksunkara pksunkara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the infer long args work for long flag subcommands?

src/build/app/settings.rs Outdated Show resolved Hide resolved
Co-authored-by: Pavan Kumar Sunkara <[email protected]>
@tertsdiepraam
Copy link
Contributor Author

tertsdiepraam commented Jun 6, 2021

I think that's already covered by InferSubcommands? This PR is compatible with that as far as I can tell. This test from flag_subcommands.rs already existed and still passes with this PR:

#[test]
fn flag_subcommand_long_infer_pass() {
    let m = App::new("prog")
        .setting(AppSettings::InferSubcommands)
        .subcommand(App::new("test").long_flag("test"))
        .get_matches_from(vec!["prog", "--te"]);
    assert_eq!(m.subcommand_name(), Some("test"));
}

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.

Allow abbreviated/unambiguous shortened long options
2 participants