mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
3 lines
14 KiB
JavaScript
3 lines
14 KiB
JavaScript
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 \nSUBCOMMANDS:\n help Prints this message\n test Controls testing features\n```\n \n## Installation\nAdd `clap` as a dependecy in your `Cargo.toml` file to use from crates.io:\n \n ```\n [dependencies]\n clap = \"*\"\n ```\n Or track the latest on the master branch at github:\n \n```\n[dependencies.clap]\ngit = \"https://github.com/kbknapp/clap-rs.git\"\n```\n \nThen run `cargo build` or `cargo update` for your project.\n \n## Usage\n \nAdd `extern crate clap;` to your crate root.\n \n## More Information\n \nYou can find complete documentation on the [github-pages site](http://kbknapp.github.io/clap-rs/docs/clap/index.html) for this project.\n \n## How to build\n \n### Running the tests\n \n```\ncargo test\n```\n \n### Building the documentation\n \nRun this instead of `cargo doc` to generate the proper module docstring:\n \n```\nmake doc\n```",null,null],[3,"Arg","","The abstract representation of a command line argument used by the consumer of the library.\n ",null,null],[12,"name","","The unique name of the argument, required",0,null],[12,"short","","The short version (i.e. single character) of the argument, no preceding `-`\n**NOTE:** `short` is mutually exclusive with `index`",0,null],[12,"long","","The long version of the flag (i.e. word) without the preceding `--`\n**NOTE:** `long` is mutually exclusive with `index`",0,null],[12,"help","","The string of text that will displayed to the user when the application's\n`help` text is displayed",0,null],[12,"required","","If this is a required by default when using the command line program\ni.e. a configuration file that's required for the program to function\n**NOTE:** required by default means, it is required *until* mutually\nexclusive arguments are evaluated.",0,null],[12,"takes_value","","Determines if this argument is an option, vice a flag or positional and\nis mutually exclusive with `index` and `multiple`",0,null],[12,"index","","The index of the argument. `index` is mutually exclusive with `takes_value`\nand `multiple`",0,null],[12,"multiple","","Determines if multiple instances of the same flag are allowed. `multiple`\nis mutually exclusive with `index` and `takes_value`.\nI.e. `-v -v -v` or `-vvv`",0,null],[12,"blacklist","","A list of names for other arguments that *may not* be used with this flag",0,null],[12,"requires","","A list of names of other arguments that are *required* to be used when\nthis flag is used",0,null],[3,"SubCommand","","The abstract representation of a command line subcommand used by the consumer of the library.\n ",null,null],[12,"name","","",1,null],[12,"matches","","",1,null],[3,"ArgMatches","","Used to get information about the arguments that\nwhere supplied to the program at runtime.",null,null],[12,"matches_of","","",2,null],[12,"flags","","",2,null],[12,"opts","","",2,null],[12,"positionals","","",2,null],[12,"subcommand","","",2,null],[3,"App","","Used to create a representation of the program and all possible command line arguments\nfor parsing at runtime.",null,null],[11,"new","","Creates a new instance of an application requiring a name (such as the binary). Will be displayed\nto the user when they print version or help and usage information.",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"author","","Sets a string of author(s)",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"about","","Sets a string briefly describing what the program does",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"version","","Sets a string of the version number",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"usage","","Sets a custom usage string to over-ride the one auto-generated by `clap`\n \n*NOTE:* You do not need to specify the \"USAGE: \" portion, as that will \nstill be applied by `clap`, you only need to specify the portion starting\nwith the binary name. \n \n*NOTE:* This will not replace the entire help message, only the portion\nshowing the usage.",3,{"inputs":[{"name":"app"},{"name":"str"}],"output":{"name":"app"}}],[11,"arg","","Adds an argument to the list of valid possibilties",3,{"inputs":[{"name":"app"},{"name":"arg"}],"output":{"name":"app"}}],[11,"args","","Adds multiple arguments to the list of valid possibilties",3,{"inputs":[{"name":"app"},{"name":"vec"}],"output":{"name":"app"}}],[11,"subcommand","","Adds a subcommand to the list of valid possibilties. Subcommands\nare effectively sub apps, because they can contain their own arguments\nand subcommands. They also function just like apps, in that they get their\nown auto generated help and version switches.",3,{"inputs":[{"name":"app"},{"name":"app"}],"output":{"name":"app"}}],[11,"subcommands","","Adds multiple subcommands to the list of valid possibilties",3,{"inputs":[{"name":"app"},{"name":"vec"}],"output":{"name":"app"}}],[11,"get_matches","","",3,{"inputs":[{"name":"app"}],"output":{"name":"argmatches"}}],[11,"new","","Creates a new instace of `Arg` using a unique string name.\nThe name will be used by the library consumer to get information about\nwhether or not the argument was used at runtime. ",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"short","","Sets the short version of the argument without the preceding `-`.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"long","","Sets the long version of the argument without the preceding `--`.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"help","","Sets the help text of the argument that will be displayed to the user\nwhen they print the usage/help information. ",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"required","","Sets whether or not the argument is required by default. Required by\ndefault means it is required, when no other mutually exlusive rules have\nbeen evaluated. Mutually exclusive rules take precedence over being required\nby default.",0,{"inputs":[{"name":"arg"},{"name":"bool"}],"output":{"name":"arg"}}],[11,"mutually_excludes","","Sets a mutually exclusive argument by name. I.e. when using this argument,\nthe following argument can't be present.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"mutually_excludes_all","","Sets a mutually exclusive arguments by names. I.e. when using this argument,\nthe following argument can't be present.",0,{"inputs":[{"name":"arg"},{"name":"vec"}],"output":{"name":"arg"}}],[11,"requires","","Sets an argument by name that is required when this one is presnet I.e. when\nusing this argument, the following argument *must* be present.",0,{"inputs":[{"name":"arg"},{"name":"str"}],"output":{"name":"arg"}}],[11,"requires_all","","Sets arguments by names that are required when this one is presnet I.e. when\nusing this argument, the following arguments *must* be present.",0,{"inputs":[{"name":"arg"},{"name":"vec"}],"output":{"name":"arg"}}],[11,"takes_value","","Specifies that the argument takes an additional value at run time.\n \n**NOTE:** When setting this to `true` the `name` of the argument\nwill be used when printing the help/usage information to the user. ",0,{"inputs":[{"name":"arg"},{"name":"bool"}],"output":{"name":"arg"}}],[11,"index","","Specifies the index of a positional argument starting at 1.\n \n**NOTE:** When setting this, any `short` or `long` values you set\nare ignored as positional arguments cannot have a `short` or `long`.\nAlso, the name will be used when printing the help/usage information \nto the user. ",0,{"inputs":[{"name":"arg"},{"name":"u8"}],"output":{"name":"arg"}}],[11,"multiple","","Specifies if the flag may appear more than once such as for multiple debugging\nlevels (as an example). `-ddd` for three levels of debugging, or `-d -d -d`. \nWhen this is set to `true` you recieve the number of occurances the user supplied\nof a particular flag at runtime.\n \n**NOTE:** When setting this, any `takes_value` or `index` values you set\nare ignored as flags cannot have a values or an `index`.",0,{"inputs":[{"name":"arg"},{"name":"bool"}],"output":{"name":"arg"}}],[11,"new","","Creates a new instance of `ArgMatches`. This ins't called directly, but\nthrough the `.get_matches()` method of `App`",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"argmatches"}}],[11,"value_of","","Gets the value of a specific option or positional argument (i.e. an argument that takes\nan additional value at runtime). If the option wasn't present at runtime\nit returns `None`. ",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"option"}}],[11,"values_of","","Gets the values of a specific option in a vector (i.e. an argument that takes\nan additional value at runtime). If the option wasn't present at runtime\nit returns `None`",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"option"}}],[11,"is_present","","Checks if a flag was argument was supplied at runtime. **DOES NOT** work for\noption or positional arguments (use `.value_of()` instead)",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"bool"}}],[11,"occurrences_of","","Checks the number of occurrences of an option or flag at runtime.\nIf an option or flag isn't present it will return `0`, if the option or flag doesn't \nallow multiple occurrences, it will return `1` no matter how many times it occurred \n(unless it wasn't prsent) at all.",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"u8"}}],[11,"subcommand_matches","","If a subcommand was found, returns the ArgMatches struct associated with it's matches",2,{"inputs":[{"name":"argmatches"},{"name":"str"}],"output":{"name":"option"}}],[11,"subcommand_name","","If a subcommand was found, returns the name associated with it",2,{"inputs":[{"name":"argmatches"}],"output":{"name":"option"}}],[11,"new","","Creates a new instance of a subcommand requiring a name. Will be displayed\nto the user when they print version or help and usage information.",1,{"inputs":[{"name":"subcommand"},{"name":"str"}],"output":{"name":"app"}}]],"paths":[[3,"Arg"],[3,"SubCommand"],[3,"ArgMatches"],[3,"App"]]};
|
|
initSearch(searchIndex);
|