From 99dfe7404a41cdfdec5d09352e8ec21af57be450 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 21 Sep 2022 11:02:06 -0500 Subject: [PATCH] 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. --- Cargo.toml | 5 ---- examples/derive_ref/custom-bool.md | 44 ------------------------------ examples/derive_ref/custom-bool.rs | 32 ---------------------- src/_derive/mod.rs | 1 - 4 files changed, 82 deletions(-) delete mode 100644 examples/derive_ref/custom-bool.md delete mode 100644 examples/derive_ref/custom-bool.rs diff --git a/Cargo.toml b/Cargo.toml index 38dd5bba3b3..e70ed6a5623 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -350,11 +350,6 @@ path = "examples/tutorial_derive/05_01_assert.rs" required-features = ["derive"] test = true -[[example]] -name = "custom-bool" -path = "examples/derive_ref/custom-bool.rs" -required-features = ["derive"] - [[example]] name = "interop_augment_args" path = "examples/derive_ref/augment_args.rs" diff --git a/examples/derive_ref/custom-bool.md b/examples/derive_ref/custom-bool.md deleted file mode 100644 index 04e3ff0ce40..00000000000 --- a/examples/derive_ref/custom-bool.md +++ /dev/null @@ -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 - -Arguments: - [possible values: true, false] - -Options: - --foo [possible values: true, false] - --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 - - -Usage: custom-bool[EXE] --foo - -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, -} - -``` diff --git a/examples/derive_ref/custom-bool.rs b/examples/derive_ref/custom-bool.rs deleted file mode 100644 index ee2d60743e1..00000000000 --- a/examples/derive_ref/custom-bool.rs +++ /dev/null @@ -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 { - match s { - "true" => Ok(true), - "false" => Ok(false), - _ => Err("expected `true` or `false`"), - } -} - -fn main() { - let opt = Opt::parse(); - dbg!(opt); -} diff --git a/src/_derive/mod.rs b/src/_derive/mod.rs index 6be1bfd1e35..2f5f97a0355 100644 --- a/src/_derive/mod.rs +++ b/src/_derive/mod.rs @@ -265,7 +265,6 @@ //! //! Notes: //! - 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>` 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)` //!