docs(ref): Remove dead example

This was missed in the migration to the reference being on docs.rs.  Not
feeling its worth finding a way to integrate it into the new structure.
This commit is contained in:
Ed Page 2022-09-21 11:02:06 -05:00
parent 16c46b4b3b
commit 99dfe7404a
4 changed files with 0 additions and 82 deletions

View file

@ -350,11 +350,6 @@ path = "examples/tutorial_derive/05_01_assert.rs"
required-features = ["derive"] required-features = ["derive"]
test = true test = true
[[example]]
name = "custom-bool"
path = "examples/derive_ref/custom-bool.rs"
required-features = ["derive"]
[[example]] [[example]]
name = "interop_augment_args" name = "interop_augment_args"
path = "examples/derive_ref/augment_args.rs" path = "examples/derive_ref/augment_args.rs"

View file

@ -1,44 +0,0 @@
*Jump to [source](custom-bool.rs)*
Example of overriding the magic `bool` behavior
```console
$ custom-bool --help
A simple to use, efficient, and full-featured Command Line Argument Parser
Usage: custom-bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
Arguments:
<BOOM> [possible values: true, false]
Options:
--foo <FOO> [possible values: true, false]
--bar <BAR> [default: false]
-h, --help Print help information
-V, --version Print version information
$ custom-bool
? failed
error: The following required arguments were not provided:
--foo <FOO>
<BOOM>
Usage: custom-bool[EXE] --foo <FOO> <BOOM>
For more information try '--help'
$ custom-bool --foo true false
[examples/derive_ref/custom-bool.rs:31] opt = Opt {
foo: true,
bar: false,
boom: false,
}
$ custom-bool --foo true --bar true false
[examples/derive_ref/custom-bool.rs:31] opt = Opt {
foo: true,
bar: true,
boom: false,
}
```

View file

@ -1,32 +0,0 @@
use clap::Parser;
#[derive(Parser, Debug, PartialEq)]
#[command(author, version, about, long_about = None)]
struct Opt {
// Default parser for `Set` is FromStr::from_str.
// `impl FromStr for bool` parses `true` or `false` so this
// works as expected.
#[arg(long, action = clap::ArgAction::Set)]
foo: bool,
// Of course, this could be done with an explicit parser function.
#[arg(long, action = clap::ArgAction::Set, value_parser = true_or_false, default_value_t)]
bar: bool,
// `bool` can be positional only with explicit `action` annotation
#[arg(action = clap::ArgAction::Set)]
boom: bool,
}
fn true_or_false(s: &str) -> Result<bool, &'static str> {
match s {
"true" => Ok(true),
"false" => Ok(false),
_ => Err("expected `true` or `false`"),
}
}
fn main() {
let opt = Opt::parse();
dbg!(opt);
}

View file

@ -265,7 +265,6 @@
//! //!
//! Notes: //! Notes:
//! - For custom type behavior, you can override the implied attributes/settings and/or set additional ones //! - For custom type behavior, you can override the implied attributes/settings and/or set additional ones
//! - For example, see [custom-bool](./custom-bool.md)
//! - `Option<Vec<T>>` will be `None` instead of `vec![]` if no arguments are provided. //! - `Option<Vec<T>>` will be `None` instead of `vec![]` if no arguments are provided.
//! - This gives the user some flexibility in designing their argument, like with `min_values(0)` //! - This gives the user some flexibility in designing their argument, like with `min_values(0)`
//! //!