Skip to content

Commit

Permalink
docs(ClapErrorType): changed examples content
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinatorul committed Sep 5, 2015
1 parent fddd676 commit b9ca261
Showing 1 changed file with 50 additions and 60 deletions.
110 changes: 50 additions & 60 deletions src/app/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg};
/// # let result = App::new("myprog")
/// # .arg(
/// # Arg::with_name("debug").index(1)
/// .possible_value("fast")
/// .possible_value("slow")
/// # ).get_matches_from_safe(vec!["", "other"]);
/// let result = App::new("myprog")
/// .arg(Arg::with_name("debug").index(1)
/// .possible_value("fast")
/// .possible_value("slow"))
/// .get_matches_from_safe(vec!["", "other"]);
/// ```
InvalidValue,
/// Error occurs when clap found unexpected flag or option
Expand All @@ -26,10 +25,9 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg};
/// # let result = App::new("myprog")
/// # .arg(
/// # Arg::from_usage("-f, --flag 'some flag'")
/// # ).get_matches_from_safe(vec!["", "--other"]);
/// let result = App::new("myprog")
/// .arg(Arg::from_usage("-f, --flag 'some flag'"))
/// .get_matches_from_safe(vec!["", "--other"]);
/// ```
InvalidArgument,
/// Error occurs when clap found unexpected subcommand
Expand All @@ -39,14 +37,13 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg, SubCommand};
/// # let result = App::new("myprog")
/// # .subcommand(
/// SubCommand::with_name("conifg")
/// .about("Used for configuration")
/// .arg(Arg::with_name("config_file")
/// .help("The configuration file to use")
/// .index(1))
/// # ).get_matches_from_safe(vec!["", "other"]);
/// let result = App::new("myprog")
/// .subcommand(SubCommand::with_name("conifg")
/// .about("Used for configuration")
/// .arg(Arg::with_name("config_file")
/// .help("The configuration file to use")
/// .index(1)))
/// .get_matches_from_safe(vec!["", "other"]);
/// ```
InvalidSubcommand,
/// Error occurs when option does not allow empty values but some was found
Expand All @@ -56,13 +53,11 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg};
/// # let result = App::new("myprog")
/// # .arg(
/// # Arg::with_name("debug")
/// .empty_values(false))
/// # .arg(
/// # Arg::with_name("color")
/// # ).get_matches_from_safe(vec!["", "--debug", "--color"]);
/// let result = App::new("myprog")
/// .arg(Arg::with_name("debug")
/// .empty_values(false))
/// .arg(Arg::with_name("color"))
/// .get_matches_from_safe(vec!["", "--debug", "--color"]);
/// ```
EmptyValue,
/// Parser inner error
Expand All @@ -78,11 +73,10 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg};
/// # let result = App::new("myprog")
/// # .arg(
/// # Arg::with_name("debug").index(1)
/// .max_values(2)
/// # ).get_matches_from_safe(vec!["", "too", "much", "values"]);
/// let result = App::new("myprog")
/// .arg(Arg::with_name("debug").index(1)
/// .max_values(2))
/// .get_matches_from_safe(vec!["", "too", "much", "values"]);
/// ```
TooMuchValues,
/// Error occurs when argument got less values then were expected
Expand All @@ -92,11 +86,10 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg};
/// # let result = App::new("myprog")
/// # .arg(
/// # Arg::with_name("debug").index(1)
/// .min_values(3)
/// # ).get_matches_from_safe(vec!["", "too", "few"]);
/// let result = App::new("myprog")
/// .arg(Arg::with_name("debug").index(1)
/// .min_values(3))
/// .get_matches_from_safe(vec!["", "too", "few"]);
/// ```
TooFewValues,
/// Error occurs when clap find two ore more conflicting arguments
Expand All @@ -106,11 +99,10 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg};
/// # let result = App::new("myprog")
/// # .arg(
/// # Arg::with_name("debug")
/// .conflicts_with("color")
/// # ).get_matches_from_safe(vec!["", "--debug", "--color"]);
/// let result = App::new("myprog")
/// .arg(Arg::with_name("debug")
/// .conflicts_with("color"))
/// .get_matches_from_safe(vec!["", "--debug", "--color"]);
/// ```
ArgumentConflict,
/// Error occurs when one or more required arguments missing
Expand All @@ -120,11 +112,10 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg};
/// # let result = App::new("myprog")
/// # .arg(
/// # Arg::with_name("debug")
/// .required(true)
/// # ).get_matches_from_safe(vec![""]);
/// let result = App::new("myprog")
/// .arg(Arg::with_name("debug")
/// .required(true))
/// .get_matches_from_safe(vec![""]);
/// ```
MissingRequiredArgument,
/// Error occurs when required subcommand missing
Expand All @@ -134,15 +125,14 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg, AppSettings, SubCommand};
/// # let result = App::new("myprog")
/// # .setting(AppSettings::SubcommandRequired)
/// # .subcommand(
/// SubCommand::with_name("conifg")
/// .about("Used for configuration")
/// .arg(Arg::with_name("config_file")
/// .help("The configuration file to use")
/// .index(1))
/// # ).get_matches_from_safe(vec![""]);
/// let result = App::new("myprog")
/// .setting(AppSettings::SubcommandRequired)
/// .subcommand(SubCommand::with_name("conifg")
/// .about("Used for configuration")
/// .arg(Arg::with_name("config_file")
/// .help("The configuration file to use")
/// .index(1)))
/// .get_matches_from_safe(vec![""]);
/// ```
MissingSubcommand,
/// Error occurs when clap find argument while is was not expecting any
Expand All @@ -152,7 +142,8 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App};
/// # let result = App::new("myprog").get_matches_from_safe(vec!["", "--arg"]);
/// let result = App::new("myprog")
/// .get_matches_from_safe(vec!["", "--arg"]);
/// ```
UnexpectedArgument,
/// Error occurs when argument was used multiple times and was not set as multiple.
Expand All @@ -162,11 +153,10 @@ pub enum ClapErrorType {
///
/// ```no_run
/// # use clap::{App, Arg};
/// # let result = App::new("myprog")
/// # .arg(
/// # Arg::with_name("debug")
/// .multiple(false)
/// # ).get_matches_from_safe(vec!["", "--debug", "--debug"]);
/// let result = App::new("myprog")
/// .arg(Arg::with_name("debug")
/// .multiple(false))
/// .get_matches_from_safe(vec!["", "--debug", "--debug"]);
/// ```
UnexpectedMultipleUsage
}
Expand Down

0 comments on commit b9ca261

Please sign in to comment.