-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Issue 442 #443
Commits on Mar 9, 2016
-
Configuration menu - View commit details
-
Copy full SHA for 06c729f - Browse repository at this point
Copy the full SHA 06c729fView commit details
Commits on Mar 10, 2016
-
feat(Opts and Flags): adds support for custom ordering in help messages
Allows custom ordering of args within the help message. Args with a lower value will be displayed first in the help message. This is helpful when one would like to emphasise frequently used args, or prioritize those towards the top of the list. Duplicate values **are** allowed. Args with duplicate display orders will be displayed in alphabetical order. **NOTE:** The default is 999 for all arguments. **NOTE:** This setting is ignored for positional arguments which are always displayed in index order. ```rust use clap::{App, Arg}; let m = App::new("cust-ord") .arg(Arg::with_name("a") // typically args are grouped by alphabetically by name // Args without a display_order have a value of 999 and are // displayed alphabetically with all other 999 args .long("long-option") .short("o") .takes_value(true) .help("Some help and text")) .arg(Arg::with_name("b") .long("other-option") .short("O") .takes_value(true) .display_order(1) // Let's force this arg to appear *first* // all we have to do is give it a value lower than 999 // any other args with a value of 1 would be displayed // alphabetically with other 1 args. Then 2, then 3, etc. .help("I should be first!")) .get_matches_from(vec![ "cust-ord", "--help" ]); ``` The above example displays the following help message ``` cust-ord USAGE: cust-ord [FLAGS] [OPTIONS] FLAGS: -h, --help Prints help information -V, --version Prints version information OPTIONS: -O, --other-option <b> I should be first! -o, --long-option <a> Some help and text ```
Configuration menu - View commit details
-
Copy full SHA for 9803b51 - Browse repository at this point
Copy the full SHA 9803b51View commit details -
feat(Subcommands): adds support for custom ordering in help messages
Allows custom ordering of subcommands within the help message. Subcommands with a lower value will be displayed first in the help message. This is helpful when one would like to emphasise frequently used subcommands, or prioritize those towards the top of the list. Duplicate values **are** allowed. Subcommands with duplicate display orders will be displayed in alphabetical order. **NOTE:** The default is 999 for all subcommands. ```rust use clap::{App, SubCommand}; let m = App::new("cust-ord") .subcommand(SubCommand::with_name("alpha") // typically subcommands are grouped // alphabetically by name. Subcommands // without a display_order have a value of // 999 and are displayed alphabetically with // all other 999 subcommands .about("Some help and text")) .subcommand(SubCommand::with_name("beta") .display_order(1) // In order to force this subcommand to appear *first* // all we have to do is give it a value lower than 999. // Any other subcommands with a value of 1 will be displayed // alphabetically with this one...then 2 values, then 3, etc. .about("I should be first!")) .get_matches_from(vec![ "cust-ord", "--help" ]); ``` The above example displays the following help message ``` cust-ord USAGE: cust-ord [FLAGS] [OPTIONS] FLAGS: -h, --help Prints help information -V, --version Prints version information SUBCOMMANDS: beta I should be first! alpha Some help and text ``` Closes #442
Configuration menu - View commit details
-
Copy full SHA for 7d2a2ed - Browse repository at this point
Copy the full SHA 7d2a2edView commit details -
Configuration menu - View commit details
-
Copy full SHA for 927d1da - Browse repository at this point
Copy the full SHA 927d1daView commit details -
Configuration menu - View commit details
-
Copy full SHA for e41a2f1 - Browse repository at this point
Copy the full SHA e41a2f1View commit details -
1
Configuration menu - View commit details
-
Copy full SHA for 4ff0205 - Browse repository at this point
Copy the full SHA 4ff0205View commit details
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.