clap/docs/search-index.js

4 lines
14 KiB
JavaScript
Raw Normal View History

2015-02-28 18:49:33 +00:00
var searchIndex = {};
searchIndex['clap'] = {"items":[[0,"","clap","# clap\n \n![Travis-CI](https://travis-ci.org/kbknapp/clap-rs.svg?branch=master)\n \nCommand Line Argument Parser written in Rust\n \nA simply library for parsing command line arguments and subcommands when writing command line and console applications.\n \nYou can use `clap` to lay out a list of possible valid command line arguments and subcommands, then let `clap` parse the string given by the user at runtime.\n \nWhen using `clap` you define a set of parameters and rules for your arguments and subcommands, then at runtime `clap` will determine their validity.\n \n`clap` also provides the traditional version and help switches 'for free' by parsing the list of possible valid arguments lazily at runtime, and if not already defined by the developer `clap` will autogenerate all applicable \"help\" and \"version\" switches (as well as a \"help\" subcommand if other subcommands are defined as well).\n \n After defining a list of possible valid arguments and subcommands, `clap` gives you a list of valid matches that the user supplied at runtime, or informs the user of their error and exits gracefully. You can use this list to determine the functioning of your program.\n \n## Quick Example\n \n```rust\n// (Full example with comments in examples/myapp.rs)\nextern crate clap;\nuse clap::{Arg, App, SubCommand};\n \nfn main() {\n let matches = App::new(\"MyApp\")\n .version(\"1.0\")\n .author(\"Kevin K. <kbknapp@gmail.com>\")\n .about(\"Does awesome things\")\n .arg(Arg::new(\"config\")\n .short(\"c\")\n .long(\"config\")\n .help(\"Sets a custom config file\")\n .takes_value(true))\n .arg(Arg::new(\"output\")\n .help(\"Sets an optional output file\")\n .index(1))\n .arg(Arg::new(\"debug\")\n .short(\"d\")\n .multiple(true)\n .help(\"Turn debugging information on\"))\n .subcommand(SubCommand::new(\"test\")\n .about(\"controls testing features\")\n .arg(Arg::new(\"verbose\")\n .short(\"v\")\n .help(\"print test information verbosely\")))\n .get_matches();\n \n if let Some(o) = matches.value_of(\"output\") {\n println!(\"Value for output: {}\", o);\n }\n \n if let Some(c) = matches.value_of(\"config\") {\n println!(\"Value for config: {}\", c);\n }\n \n match matches.occurrences_of(\"debug\") {\n 0 => println!(\"Debug mode is off\"),\n 1 => println!(\"Debug mode is kind of on\"),\n 2 => println!(\"Debug mode is on\"),\n 3 | _ => println!(\"Don't be crazy\"),\n }\n \n if let Some(ref matches) = matches.subcommand_matches(\"test\") {\n if matches.is_present(\"verbose\") {\n println!(\"Printing verbosely...\");\n } else {\n println!(\"Printing normally...\");\n }\n }\n \n // more porgram logic goes here...\n}\n```\n \nIf you were to compile the above program and run it with the flag `--help` or `-h` (or `help` subcommand, since we defined `test` as a subcommand) the following output woud be presented\n \n```sh\n$ myprog --help\nMyApp 1.0\nKevin K. <kbknapp@gmail.com>\nDoes awesome things\n \nUSAGE:\n MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]\n \nFLAGS:\n -d Turn debugging information on\n -h,--help Prints this message\n -v,--version Prints version information\n \nOPTIONS:\n -c,--config <config> Sets a custom config file\n \nPOSITIONAL ARGUMENTS:\n output Sets an optional output file\n \nSUBCOM
2015-02-28 18:49:33 +00:00
initSearch(searchIndex);