Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Clean up usage of #[derive(Parser)] #23

Merged
merged 2 commits into from
Sep 22, 2022
Merged

Clean up usage of #[derive(Parser)] #23

merged 2 commits into from
Sep 22, 2022

Conversation

egregius313
Copy link
Collaborator

Mostly cosmetic changes. Provides clean up of the usage of #[derive(Parser)]
in the following ways:

  1. Makes all attributes of Opts use the comment syntax for defining the help
    message.

  2. Uses the short form of the short and long metadata declarations.
    #[derive(Parser)] treats

    struct Example {
        #[clap(short, long)]
        arg: u8,
    }

    the same as

    struct Example {
        #[clap(short = 'a', long = "arg")]
        arg: u8,
    }

`#[clap(...)]` automatically sets the short and long flags for a CLI
flag from the name of the attribute of the struct.
Copy link
Owner

@CleanCut CleanCut left a comment

Choose a reason for hiding this comment

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

TIL!

@CleanCut CleanCut merged commit 4d8303e into main Sep 22, 2022
@CleanCut CleanCut deleted the clap-derive-cleanup branch September 22, 2022 20:33
@CleanCut
Copy link
Owner

Released in v0.3.2

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants