<commit_before>//! Docopt for Rust. This implementation conforms to the
//! [official description of Docopt](http://docopt.org/) and
//! [passes its test suite](https://github.com/docopt/docopt/pull/201).
//!
//! This library is [on GitHub](https://github.com/BurntSushi/docopt.rs)
//! and is currently very experimental, particularly with respect to the
//! API and its use of macros. Feedback is **very** welcome.
//!
//! Fundamentally, Docopt is a command line argument parser. The detail that
//! distinguishes it from most parsers is that the parser is derived from the
//! usage string. Here's a simple example using the `docopt!` macro:
//!
//! ```rust
//! #![feature(phase)]
//! extern crate serialize;
//! #[phase(plugin, link)] extern crate docopt;
//!
//! docopt!(Args, "
//! Usage: cp [-a] SOURCE DEST
//!        cp [-a] SOURCE... DIR
//! 
//! Options:
//!     -a, --archive  Copy everything.
//! ")
//!
//! fn main() {
//!     let argv = &["-a", "file1", "file2", "dest/"];
//!     let args = Args::parse_args(docopt::DEFAULT_CONFIG.clone(), argv);
//!     assert!(args.flag_archive);
//!     assert_eq!(args.arg_SOURCE, vec!["file1".to_string(), "file2".to_string()]);
//!     assert_eq!(args.arg_DIR, "dest/".to_string());
//! }
//! ```
//!
//! Wait. What did that just do? Yup. It *created a struct definition* for
//! you. In this case, the struct definition would look like this:
//!
//! ```ignore
//! #[deriving(Decodable, Show)]
//! struct Args {
//!     pub flag_archive: bool,
//!     pub arg_DEST: String,
//!     pub arg_DIR: String,
//!     pub arg_SOURCE: Vec<String>,
//! }
//! ```
//!
//! There are also some accompanying static methods defined, such as `parse`,
//! `parse_conf` and `parse_args`. These methods will parse command line
//! arguments, try to match them against your Docopt usage string and then
//! try to decode matched values into the struct.
//!
//! If you're thinking that this is too much magic, then you may be right. This
//! API should be considered experimental. I do not yet know what the right
//! level of magic is. Therefore, you can use an API that is less convenient
//! but with absolutely no magic. Here's the same `cp` example above, but
//! using a hash table instead:
//!
//! ```rust
//! extern crate docopt;
//!
//! fn main() {
//!     let config = docopt::DEFAULT_CONFIG.clone();
//!     let argv = &["-a", "file1", "file2", "dest/"];
//!     let args = docopt::docopt_args(config, argv, "
//! Usage: cp [-a] SOURCE DEST
//!        cp [-a] SOURCE... DIR
//! 
//! Options:
//!     -a, --archive  Copy everything.
//!     ");
//!     assert!(args.get_bool("-a") && args.get_bool("--archive"));
//!     assert_eq!(args.get_vec("SOURCE"), vec!["file1", "file2"]);
//!     assert_eq!(args.get_str("DIR"), "dest/");
//! }
//! ```
//!
//! # Command line arguments for `rustc`
//!
//! Here's an example (with a macro) showing a subset of `rustc`'s command
//! line arguments.
//!
//! ```rust
//! # #![feature(phase)]
//! # extern crate serialize;
//! # #[phase(plugin, link)] extern crate docopt;
//! docopt!(Args, "
//! Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT
//!        rustc (--help | --version)
//! 
//! Options:
//!     -h, --help         Show this message.
//!     --version          Show the version of rustc.
//!     --cfg SPEC         Configure the compilation environment.
//!     -L PATH            Add a directory to the library search path.
//!     --emit TYPE        Configure the output that rustc will produce.
//!                        Valid values: asm, ir, bc, obj, link.
//!     --opt-level LEVEL  Optimize with possible levels 0-3.
//! ")
//!
//! fn main() {
//!     let argv = &["--cfg", "a", "docopt.rs", "-L", ".", "-L.."];
//!     let args = Args::parse_args(docopt::DEFAULT_CONFIG.clone(), argv);
//!     assert_eq!(args.arg_INPUT, "docopt.rs".to_string());
//!     assert_eq!(args.flag_L, vec![".".to_string(), "..".to_string()]);
//!     assert_eq!(args.flag_cfg, vec!["a".to_string()]);
//! }
//! ```
//!
//! This example shows some of the more advanced features of Docopt. However,
//! there's still one large omission: data validation. In the above example,
//! *any* value can be given to `--emit` or `--opt-level`, but clearly, the
//! application defines a limited subset of all possible values.
//!
//! This is where data validation can help. In Docopt proper, it is a
//! *non-goal* to validate and convert the data. However, this implementation
//! provides some facilities to do just that. All you need to do is provide 
//! Rust types for the flags/arguments, and the decoder will do the rest. 
//! Here's an example of limiting the range of values for `--emit` and 
//! `--opt-level`:
//!
//! (Note the extra type annotations in the `docopt!` macro call.)
//!
//! ```rust
//! # #![feature(phase)]
//! # extern crate serialize;
//! # #[phase(plugin, link)] extern crate docopt;
//! docopt!(Args, "
//! Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT
//!        rustc (--help | --version)
//! 
//! Options:
//!     -h, --help         Show this message.
//!     --version          Show the version of rustc.
//!     --cfg SPEC         Configure the compilation environment.
//!     -L PATH            Add a directory to the library search path.
//!     --emit TYPE        Configure the output that rustc will produce.
//!                        Valid values: asm, ir, bc, obj, link.
//!     --opt-level LEVEL  Optimize with possible levels 0-3.
//! ", flag_opt_level: Option<OptLevel>, flag_emit: Option<Emit>)
//! 
//! // This is easy. The decoder will automatically restrict values to
//! // strings that match one of the enum variants.
//! #[deriving(Decodable, PartialEq, Show)]
//! enum Emit { Asm, Ir, Bc, Obj, Link }
//! 
//! // This one is harder because we want the user to specify an integer,
//! // but restrict it to a specific range. So we implement `Decodable`
//! // ourselves.
//! #[deriving(PartialEq, Show)]
//! enum OptLevel { Zero, One, Two, Three }
//! 
//! impl<E, D: serialize::Decoder<E>> serialize::Decodable<D, E> for OptLevel {
//!     fn decode(d: &mut D) -> Result<OptLevel, E> {
//!         Ok(match try!(d.read_uint()) {
//!             0 => Zero, 1 => One, 2 => Two, 3 => Three,
//!             // This partly defeats the purpose of this example, but
//!             // hopefully showing a wart will encourage people to help
//!             // me fix it.
//!             _ => fail!("How to CONVENIENTLY create value with type `E`?"),
//!         })
//!     }
//! }
//!
//! fn main() {
//!     let argv = &["--opt-level", "2", "--emit=ir", "docopt.rs"];
//!     let args = Args::parse_args(docopt::DEFAULT_CONFIG.clone(), argv);
//!     assert_eq!(args.flag_opt_level, Some(Two));
//!     assert_eq!(args.flag_emit, Some(Ir));
//! }
//! ```
//!
//! If you tried to pass, for example, `--emit=whatever`, then the decoding
//! would fail.

#![crate_id = "docopt#0.1.0"]
// #![crate_name = "docopt"] 
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![experimental]
#![license = "UNLICENSE"]<commit_msg>Only compile a dylib for now.<commit_after>//! Docopt for Rust. This implementation conforms to the
//! [official description of Docopt](http://docopt.org/) and
//! [passes its test suite](https://github.com/docopt/docopt/pull/201).
//!
//! This library is [on GitHub](https://github.com/BurntSushi/docopt.rs)
//! and is currently very experimental, particularly with respect to the
//! API and its use of macros. Feedback is **very** welcome.
//!
//! Fundamentally, Docopt is a command line argument parser. The detail that
//! distinguishes it from most parsers is that the parser is derived from the
//! usage string. Here's a simple example using the `docopt!` macro:
//!
//! ```rust
//! #![feature(phase)]
//! extern crate serialize;
//! #[phase(plugin, link)] extern crate docopt;
//!
//! docopt!(Args, "
//! Usage: cp [-a] SOURCE DEST
//!        cp [-a] SOURCE... DIR
//! 
//! Options:
//!     -a, --archive  Copy everything.
//! ")
//!
//! fn main() {
//!     let argv = &["-a", "file1", "file2", "dest/"];
//!     let args = Args::parse_args(docopt::DEFAULT_CONFIG.clone(), argv);
//!     assert!(args.flag_archive);
//!     assert_eq!(args.arg_SOURCE, vec!["file1".to_string(), "file2".to_string()]);
//!     assert_eq!(args.arg_DIR, "dest/".to_string());
//! }
//! ```
//!
//! Wait. What did that just do? Yup. It *created a struct definition* for
//! you. In this case, the struct definition would look like this:
//!
//! ```ignore
//! #[deriving(Decodable, Show)]
//! struct Args {
//!     pub flag_archive: bool,
//!     pub arg_DEST: String,
//!     pub arg_DIR: String,
//!     pub arg_SOURCE: Vec<String>,
//! }
//! ```
//!
//! There are also some accompanying static methods defined, such as `parse`,
//! `parse_conf` and `parse_args`. These methods will parse command line
//! arguments, try to match them against your Docopt usage string and then
//! try to decode matched values into the struct.
//!
//! If you're thinking that this is too much magic, then you may be right. This
//! API should be considered experimental. I do not yet know what the right
//! level of magic is. Therefore, you can use an API that is less convenient
//! but with absolutely no magic. Here's the same `cp` example above, but
//! using a hash table instead:
//!
//! ```rust
//! extern crate docopt;
//!
//! fn main() {
//!     let config = docopt::DEFAULT_CONFIG.clone();
//!     let argv = &["-a", "file1", "file2", "dest/"];
//!     let args = docopt::docopt_args(config, argv, "
//! Usage: cp [-a] SOURCE DEST
//!        cp [-a] SOURCE... DIR
//! 
//! Options:
//!     -a, --archive  Copy everything.
//!     ");
//!     assert!(args.get_bool("-a") && args.get_bool("--archive"));
//!     assert_eq!(args.get_vec("SOURCE"), vec!["file1", "file2"]);
//!     assert_eq!(args.get_str("DIR"), "dest/");
//! }
//! ```
//!
//! # Command line arguments for `rustc`
//!
//! Here's an example (with a macro) showing a subset of `rustc`'s command
//! line arguments.
//!
//! ```rust
//! # #![feature(phase)]
//! # extern crate serialize;
//! # #[phase(plugin, link)] extern crate docopt;
//! docopt!(Args, "
//! Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT
//!        rustc (--help | --version)
//! 
//! Options:
//!     -h, --help         Show this message.
//!     --version          Show the version of rustc.
//!     --cfg SPEC         Configure the compilation environment.
//!     -L PATH            Add a directory to the library search path.
//!     --emit TYPE        Configure the output that rustc will produce.
//!                        Valid values: asm, ir, bc, obj, link.
//!     --opt-level LEVEL  Optimize with possible levels 0-3.
//! ")
//!
//! fn main() {
//!     let argv = &["--cfg", "a", "docopt.rs", "-L", ".", "-L.."];
//!     let args = Args::parse_args(docopt::DEFAULT_CONFIG.clone(), argv);
//!     assert_eq!(args.arg_INPUT, "docopt.rs".to_string());
//!     assert_eq!(args.flag_L, vec![".".to_string(), "..".to_string()]);
//!     assert_eq!(args.flag_cfg, vec!["a".to_string()]);
//! }
//! ```
//!
//! This example shows some of the more advanced features of Docopt. However,
//! there's still one large omission: data validation. In the above example,
//! *any* value can be given to `--emit` or `--opt-level`, but clearly, the
//! application defines a limited subset of all possible values.
//!
//! This is where data validation can help. In Docopt proper, it is a
//! *non-goal* to validate and convert the data. However, this implementation
//! provides some facilities to do just that. All you need to do is provide 
//! Rust types for the flags/arguments, and the decoder will do the rest. 
//! Here's an example of limiting the range of values for `--emit` and 
//! `--opt-level`:
//!
//! (Note the extra type annotations in the `docopt!` macro call.)
//!
//! ```rust
//! # #![feature(phase)]
//! # extern crate serialize;
//! # #[phase(plugin, link)] extern crate docopt;
//! docopt!(Args, "
//! Usage: rustc [options] [--cfg SPEC... -L PATH...] INPUT
//!        rustc (--help | --version)
//! 
//! Options:
//!     -h, --help         Show this message.
//!     --version          Show the version of rustc.
//!     --cfg SPEC         Configure the compilation environment.
//!     -L PATH            Add a directory to the library search path.
//!     --emit TYPE        Configure the output that rustc will produce.
//!                        Valid values: asm, ir, bc, obj, link.
//!     --opt-level LEVEL  Optimize with possible levels 0-3.
//! ", flag_opt_level: Option<OptLevel>, flag_emit: Option<Emit>)
//! 
//! // This is easy. The decoder will automatically restrict values to
//! // strings that match one of the enum variants.
//! #[deriving(Decodable, PartialEq, Show)]
//! enum Emit { Asm, Ir, Bc, Obj, Link }
//! 
//! // This one is harder because we want the user to specify an integer,
//! // but restrict it to a specific range. So we implement `Decodable`
//! // ourselves.
//! #[deriving(PartialEq, Show)]
//! enum OptLevel { Zero, One, Two, Three }
//! 
//! impl<E, D: serialize::Decoder<E>> serialize::Decodable<D, E> for OptLevel {
//!     fn decode(d: &mut D) -> Result<OptLevel, E> {
//!         Ok(match try!(d.read_uint()) {
//!             0 => Zero, 1 => One, 2 => Two, 3 => Three,
//!             // This partly defeats the purpose of this example, but
//!             // hopefully showing a wart will encourage people to help
//!             // me fix it.
//!             _ => fail!("How to CONVENIENTLY create value with type `E`?"),
//!         })
//!     }
//! }
//!
//! fn main() {
//!     let argv = &["--opt-level", "2", "--emit=ir", "docopt.rs"];
//!     let args = Args::parse_args(docopt::DEFAULT_CONFIG.clone(), argv);
//!     assert_eq!(args.flag_opt_level, Some(Two));
//!     assert_eq!(args.flag_emit, Some(Ir));
//! }
//! ```
//!
//! If you tried to pass, for example, `--emit=whatever`, then the decoding
//! would fail.

#![crate_name = "docopt"]
// #![crate_type = "rlib"] 
#![crate_type = "dylib"]
#![experimental]
#![license = "UNLICENSE"]
{'fraction_non_alphanumeric': 0.19623846699787084, 'fraction_numerical': 0.0030518097941802697, 'mean_word_length': 2.5440140845070425, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6757486', 'n_tokens_mistral': 4685, 'n_tokens_neox': 4291, 'n_words': 1518}