2015-03-19 21:55:13 +00:00
|
|
|
extern crate clap;
|
|
|
|
|
2016-01-21 05:18:53 +00:00
|
|
|
use clap::App;
|
2015-03-19 21:55:13 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Apps describe the top level application
|
|
|
|
//
|
2015-03-20 16:47:28 +00:00
|
|
|
// You create an App and set various options on that App using the "builder pattern"
|
2015-03-19 21:55:13 +00:00
|
|
|
//
|
2015-03-20 16:47:28 +00:00
|
|
|
// 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.
|
|
|
|
//
|
2018-10-19 20:42:13 +00:00
|
|
|
// You also set all the valid arguments your App should accept via the arg(), args(), arg()
|
2015-04-14 02:18:50 +00:00
|
|
|
// and args_from_usage() (as well as subcommands via the subcommand() and subcommands() methods) which
|
|
|
|
// will be covered later.
|
2015-03-20 16:47:28 +00:00
|
|
|
//
|
2016-01-27 22:22:34 +00:00
|
|
|
// 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.
|
2015-08-30 20:16:35 +00:00
|
|
|
App::new("MyApp")
|
|
|
|
.version("1.0")
|
2016-01-21 05:18:53 +00:00
|
|
|
.author("Kevin K. <kbknapp@gmail.com>")
|
|
|
|
.about("Does awesome things")
|
|
|
|
.get_matches();
|
2015-04-14 02:18:50 +00:00
|
|
|
|
2015-06-17 00:46:11 +00:00
|
|
|
// This example doesn't do much, but it *does* give automatic -h, --help, -V, and --version functionality ;)
|
2015-10-01 01:45:35 +00:00
|
|
|
|
2015-03-19 21:55:13 +00:00
|
|
|
// Continued program logic goes here...
|
|
|
|
}
|