mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
bfa02fd418
This ports our example testing over to [trycmd](https://docs.rs/) so we can: - More thoroughly test our examples - Provide always-up-to-date example usage The old way of testing automatically picked up examples. This new way requires we have a `.md` file that uses the example in some way. Notes: - Moved overall example description to the `.md` file - I added cross-linking between related examples - `14_groups` had a redundant paragraph (twice talked about "one and only one"
26 lines
1.2 KiB
Rust
26 lines
1.2 KiB
Rust
use clap::App;
|
|
|
|
fn main() {
|
|
// You create an App and set various options on that App using the "builder pattern"
|
|
//
|
|
// The options (version(), author(), about()) aren't mandatory, but recommended. There is
|
|
// another option, usage(), which is an exception to the rule. This should only be used when
|
|
// the default usage string automatically generated by clap doesn't suffice.
|
|
//
|
|
// You also set all the valid arguments your App should accept via the arg() and args()
|
|
// (as well as subcommands via the subcommand() and subcommands() methods) which
|
|
// will be covered later.
|
|
//
|
|
// Once all options have been set, call one of the .get_matches* family of methods in order to
|
|
// start the parsing and find all valid command line arguments that supplied by the user at
|
|
// runtime. The name given to new() will be displayed when the version or help flags are used.
|
|
App::new("MyApp")
|
|
.version("1.0")
|
|
.author("Kevin K. <kbknapp@gmail.com>")
|
|
.about("Does awesome things")
|
|
.get_matches();
|
|
|
|
// This example doesn't do much, but it *does* give automatic -h, --help, -V, and --version functionality ;)
|
|
|
|
// Continued program logic goes here...
|
|
}
|