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