docs(derive): Update for new attributes

This commit is contained in:
Ed Page 2022-09-02 15:37:23 -05:00
parent 2609b970a4
commit 0e915e0d3a
64 changed files with 498 additions and 498 deletions

View file

@ -19,41 +19,41 @@ use std::io;
use std::path::PathBuf;
#[derive(Parser, Debug, PartialEq)]
#[clap(
#[command(
name = "value_hints_derive",
// Command::trailing_var_ar is required to use ValueHint::CommandWithArguments
trailing_var_arg = true,
)]
struct Opt {
/// If provided, outputs the completion file for given shell
#[clap(long = "generate", value_enum)]
#[arg(long = "generate", value_enum)]
generator: Option<Shell>,
// Showcasing all possible ValueHints:
#[clap(long, value_hint = ValueHint::Unknown)]
#[arg(long, value_hint = ValueHint::Unknown)]
unknown: Option<String>,
#[clap(long, value_hint = ValueHint::Other)]
#[arg(long, value_hint = ValueHint::Other)]
other: Option<String>,
#[clap(short, long, value_hint = ValueHint::AnyPath)]
#[arg(short, long, value_hint = ValueHint::AnyPath)]
path: Option<PathBuf>,
#[clap(short, long, value_hint = ValueHint::FilePath)]
#[arg(short, long, value_hint = ValueHint::FilePath)]
file: Option<PathBuf>,
#[clap(short, long, value_hint = ValueHint::DirPath)]
#[arg(short, long, value_hint = ValueHint::DirPath)]
dir: Option<PathBuf>,
#[clap(short, long, value_hint = ValueHint::ExecutablePath)]
#[arg(short, long, value_hint = ValueHint::ExecutablePath)]
exe: Option<PathBuf>,
#[clap(long, value_hint = ValueHint::CommandName)]
#[arg(long, value_hint = ValueHint::CommandName)]
cmd_name: Option<OsString>,
#[clap(short, long, value_hint = ValueHint::CommandString)]
#[arg(short, long, value_hint = ValueHint::CommandString)]
cmd: Option<String>,
#[clap(value_hint = ValueHint::CommandWithArguments)]
#[arg(value_hint = ValueHint::CommandWithArguments)]
command_with_args: Vec<String>,
#[clap(short, long, value_hint = ValueHint::Username)]
#[arg(short, long, value_hint = ValueHint::Username)]
user: Option<String>,
#[clap(short, long, value_hint = ValueHint::Hostname)]
#[arg(short, long, value_hint = ValueHint::Hostname)]
host: Option<String>,
#[clap(long, value_hint = ValueHint::Url)]
#[arg(long, value_hint = ValueHint::Url)]
url: Option<String>,
#[clap(long, value_hint = ValueHint::EmailAddress)]
#[arg(long, value_hint = ValueHint::EmailAddress)]
email: Option<String>,
}

View file

@ -8,7 +8,7 @@ pub mod bash {
use unicode_xid::UnicodeXID;
#[derive(clap::Subcommand)]
#[clap(hide = true)]
#[command(hide = true)]
#[allow(missing_docs)]
#[derive(Clone, Debug)]
pub enum CompleteCommand {
@ -17,15 +17,15 @@ pub mod bash {
}
#[derive(clap::Args)]
#[clap(group = clap::ArgGroup::new("complete").multiple(true).conflicts_with("register"))]
#[command(group = clap::ArgGroup::new("complete").multiple(true).conflicts_with("register"))]
#[allow(missing_docs)]
#[derive(Clone, Debug)]
pub struct CompleteArgs {
/// Path to write completion-registration to
#[clap(long, required = true)]
#[arg(long, required = true)]
register: Option<std::path::PathBuf>,
#[clap(
#[arg(
long,
required = true,
value_name = "COMP_CWORD",
@ -34,10 +34,10 @@ pub mod bash {
)]
index: Option<usize>,
#[clap(long, hide_short_help = true, group = "complete")]
#[arg(long, hide_short_help = true, group = "complete")]
ifs: Option<String>,
#[clap(
#[arg(
long = "type",
required = true,
hide_short_help = true,
@ -45,10 +45,10 @@ pub mod bash {
)]
comp_type: Option<CompType>,
#[clap(long, hide_short_help = true, group = "complete")]
#[arg(long, hide_short_help = true, group = "complete")]
space: bool,
#[clap(
#[arg(
long,
conflicts_with = "space",
hide_short_help = true,
@ -56,7 +56,7 @@ pub mod bash {
)]
no_space: bool,
#[clap(raw = true, hide_short_help = true, group = "complete")]
#[arg(raw = true, hide_short_help = true, group = "complete")]
comp_words: Vec<OsString>,
}

View file

@ -1,16 +1,16 @@
use clap::Parser;
#[derive(Parser)] // requires `derive` feature
#[clap(name = "cargo")]
#[clap(bin_name = "cargo")]
#[command(name = "cargo")]
#[command(bin_name = "cargo")]
enum Cargo {
ExampleDerive(ExampleDerive),
}
#[derive(clap::Args)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct ExampleDerive {
#[clap(long)]
#[arg(long)]
manifest_path: Option<std::path::PathBuf>,
}

View file

@ -2,14 +2,14 @@ use clap::Parser;
/// Simple program to greet a person
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Args {
/// Name of the person to greet
#[clap(short, long)]
#[arg(short, long)]
name: String,
/// Number of times to greet
#[clap(short, long, default_value_t = 1)]
#[arg(short, long, default_value_t = 1)]
count: u8,
}

View file

@ -2,7 +2,7 @@ use clap::{arg, Args, Command, FromArgMatches as _};
#[derive(Args, Debug)]
struct DerivedArgs {
#[clap(short, long)]
#[arg(short, long)]
derived: bool,
}

View file

@ -3,7 +3,7 @@ use clap::{Command, FromArgMatches as _, Parser, Subcommand as _};
#[derive(Parser, Debug)]
enum Subcommands {
Derived {
#[clap(short, long)]
#[arg(short, long)]
derived_flag: bool,
},
}

View file

@ -1,20 +1,20 @@
use clap::Parser;
#[derive(Parser, Debug, PartialEq)]
#[clap(author, version, about, long_about = None)]
#[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.
#[clap(long, action = clap::ArgAction::Set)]
#[arg(long, action = clap::ArgAction::Set)]
foo: bool,
// Of course, this could be done with an explicit parser function.
#[clap(long, action = clap::ArgAction::Set, value_parser = true_or_false, default_value_t)]
#[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
#[clap(action = clap::ArgAction::Set)]
#[arg(action = clap::ArgAction::Set)]
boom: bool,
}

View file

@ -79,9 +79,9 @@ impl Args for CliArgs {
#[derive(Parser, Debug)]
struct Cli {
#[clap(short, long)]
#[arg(short, long)]
top_level: bool,
#[clap(flatten)]
#[command(flatten)]
more_args: CliArgs,
}

View file

@ -7,7 +7,7 @@ struct AddArgs {
}
#[derive(Parser, Debug)]
struct RemoveArgs {
#[clap(short, long)]
#[arg(short, long)]
force: bool,
name: Vec<String>,
}
@ -67,7 +67,7 @@ impl Subcommand for CliSub {
#[derive(Parser, Debug)]
struct Cli {
#[clap(short, long)]
#[arg(short, long)]
top_level: bool,
#[clap(subcommand)]
subcommand: CliSub,

View file

@ -1,15 +1,15 @@
use clap::Parser;
#[derive(Parser)] // requires `derive` feature
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[clap(short = 'f')]
#[arg(short = 'f')]
eff: bool,
#[clap(short = 'p', value_name = "PEAR")]
#[arg(short = 'p', value_name = "PEAR")]
pea: Option<String>,
#[clap(last = true)]
#[arg(last = true)]
slop: Vec<String>,
}

View file

@ -5,46 +5,46 @@ use clap::{Args, Parser, Subcommand};
/// A fictional versioning CLI
#[derive(Debug, Parser)] // requires `derive` feature
#[clap(name = "git")]
#[clap(about = "A fictional versioning CLI", long_about = None)]
#[command(name = "git")]
#[command(about = "A fictional versioning CLI", long_about = None)]
struct Cli {
#[clap(subcommand)]
#[command(subcommand)]
command: Commands,
}
#[derive(Debug, Subcommand)]
enum Commands {
/// Clones repos
#[clap(arg_required_else_help = true)]
#[command(arg_required_else_help = true)]
Clone {
/// The remote to clone
remote: String,
},
/// pushes things
#[clap(arg_required_else_help = true)]
#[command(arg_required_else_help = true)]
Push {
/// The remote to target
remote: String,
},
/// adds things
#[clap(arg_required_else_help = true)]
#[command(arg_required_else_help = true)]
Add {
/// Stuff to add
#[clap(required = true)]
#[arg(required = true)]
path: Vec<PathBuf>,
},
Stash(Stash),
#[clap(external_subcommand)]
#[command(external_subcommand)]
External(Vec<OsString>),
}
#[derive(Debug, Args)]
#[clap(args_conflicts_with_subcommands = true)]
#[command(args_conflicts_with_subcommands = true)]
struct Stash {
#[clap(subcommand)]
#[command(subcommand)]
command: Option<StashCommands>,
#[clap(flatten)]
#[command(flatten)]
push: StashPush,
}
@ -57,7 +57,7 @@ enum StashCommands {
#[derive(Debug, Args)]
struct StashPush {
#[clap(short, long)]
#[arg(short, long)]
message: Option<String>,
}

View file

@ -3,20 +3,20 @@ use std::path::PathBuf;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Optional name to operate on
name: Option<String>,
/// Sets a custom config file
#[clap(short, long, value_name = "FILE")]
#[arg(short, long, value_name = "FILE")]
config: Option<PathBuf>,
/// Turn debugging information on
#[clap(short, long, action = clap::ArgAction::Count)]
#[arg(short, long, action = clap::ArgAction::Count)]
debug: u8,
#[clap(subcommand)]
#[command(subcommand)]
command: Option<Commands>,
}
@ -25,7 +25,7 @@ enum Commands {
/// does testing things
Test {
/// lists test values
#[clap(short, long)]
#[arg(short, long)]
list: bool,
},
}

View file

@ -1,12 +1,12 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(allow_negative_numbers = true)]
#[command(author, version, about, long_about = None)]
#[command(allow_negative_numbers = true)]
struct Cli {
#[clap(long)]
#[arg(long)]
two: String,
#[clap(long)]
#[arg(long)]
one: String,
}

View file

@ -1,14 +1,14 @@
use clap::Parser;
#[derive(Parser)]
#[clap(name = "MyApp")]
#[clap(author = "Kevin K. <kbknapp@gmail.com>")]
#[clap(version = "1.0")]
#[clap(about = "Does awesome things", long_about = None)]
#[command(name = "MyApp")]
#[command(author = "Kevin K. <kbknapp@gmail.com>")]
#[command(version = "1.0")]
#[command(about = "Does awesome things", long_about = None)]
struct Cli {
#[clap(long)]
#[arg(long)]
two: String,
#[clap(long)]
#[arg(long)]
one: String,
}

View file

@ -1,11 +1,11 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)] // Read from `Cargo.toml`
#[command(author, version, about, long_about = None)] // Read from `Cargo.toml`
struct Cli {
#[clap(long)]
#[arg(long)]
two: String,
#[clap(long)]
#[arg(long)]
one: String,
}

View file

@ -1,9 +1,9 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[clap(short, long)]
#[arg(short, long)]
verbose: bool,
}

View file

@ -1,9 +1,9 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[clap(short, long, action = clap::ArgAction::Count)]
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
}

View file

@ -1,9 +1,9 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[clap(short, long)]
#[arg(short, long)]
name: Option<String>,
}

View file

@ -1,9 +1,9 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[clap(short, long)]
#[arg(short, long)]
name: Vec<String>,
}

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
name: Option<String>,
}

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
name: Vec<String>,
}

View file

@ -50,7 +50,7 @@ Options:
```
Because we added `#[clap(propagate_version = true)]`:
Because we added `#[command(propagate_version = true)]`:
```console
$ 03_04_subcommands_derive --version
clap [..]

View file

@ -1,10 +1,10 @@
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(propagate_version = true)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
struct Cli {
#[clap(subcommand)]
#[command(subcommand)]
command: Commands,
}

View file

@ -1,10 +1,10 @@
use clap::{Args, Parser, Subcommand};
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(propagate_version = true)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
struct Cli {
#[clap(subcommand)]
#[command(subcommand)]
command: Commands,
}

View file

@ -1,9 +1,9 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[clap(default_value_t = String::from("alice"))]
#[arg(default_value_t = String::from("alice"))]
name: String,
}

View file

@ -1,10 +1,10 @@
use clap::{Parser, ValueEnum};
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// What mode to run the program in
#[clap(value_enum)]
#[arg(value_enum)]
mode: Mode,
}

View file

@ -1,10 +1,10 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Network port to use
#[clap(value_parser = clap::value_parser!(u16).range(1..))]
#[arg(value_parser = clap::value_parser!(u16).range(1..))]
port: u16,
}

View file

@ -3,10 +3,10 @@ use std::ops::RangeInclusive;
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Network port to use
#[clap(value_parser = port_in_range)]
#[arg(value_parser = port_in_range)]
port: u16,
}

View file

@ -1,38 +1,38 @@
use clap::{ArgGroup, Parser};
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(group(
#[command(author, version, about, long_about = None)]
#[command(group(
ArgGroup::new("vers")
.required(true)
.args(["set_ver", "major", "minor", "patch"]),
))]
struct Cli {
/// set version manually
#[clap(long, value_name = "VER")]
#[arg(long, value_name = "VER")]
set_ver: Option<String>,
/// auto inc major
#[clap(long)]
#[arg(long)]
major: bool,
/// auto inc minor
#[clap(long)]
#[arg(long)]
minor: bool,
/// auto inc patch
#[clap(long)]
#[arg(long)]
patch: bool,
/// some regular input
#[clap(group = "input")]
#[arg(group = "input")]
input_file: Option<String>,
/// some special input argument
#[clap(long, group = "input")]
#[arg(long, group = "input")]
spec_in: Option<String>,
#[clap(short, requires = "input")]
#[arg(short, requires = "input")]
config: Option<String>,
}

View file

@ -2,32 +2,32 @@ use clap::error::ErrorKind;
use clap::{CommandFactory, Parser};
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// set version manually
#[clap(long, value_name = "VER")]
#[arg(long, value_name = "VER")]
set_ver: Option<String>,
/// auto inc major
#[clap(long)]
#[arg(long)]
major: bool,
/// auto inc minor
#[clap(long)]
#[arg(long)]
minor: bool,
/// auto inc patch
#[clap(long)]
#[arg(long)]
patch: bool,
/// some regular input
input_file: Option<String>,
/// some special input argument
#[clap(long)]
#[arg(long)]
spec_in: Option<String>,
#[clap(short)]
#[arg(short)]
config: Option<String>,
}

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Network port to use
port: u16,

View file

@ -4,23 +4,23 @@ use std::error::Error;
#[derive(Parser, Debug)] // requires `derive` feature
struct Args {
/// Implicitly using `std::str::FromStr`
#[clap(short = 'O')]
#[arg(short = 'O')]
optimization: Option<usize>,
/// Allow invalid UTF-8 paths
#[clap(short = 'I', value_name = "DIR", value_hint = clap::ValueHint::DirPath)]
#[arg(short = 'I', value_name = "DIR", value_hint = clap::ValueHint::DirPath)]
include: Option<std::path::PathBuf>,
/// Handle IP addresses
#[clap(long)]
#[arg(long)]
bind: Option<std::net::IpAddr>,
/// Allow human-readable durations
#[clap(long)]
#[arg(long)]
sleep: Option<humantime::Duration>,
/// Hand-written parser for tuples
#[clap(short = 'D', value_parser = parse_key_val::<String, i32>)]
#[arg(short = 'D', value_parser = parse_key_val::<String, i32>)]
defines: Vec<(String, i32)>,
}

View file

@ -49,7 +49,7 @@
//!
#![doc = include_str!("../../examples/tutorial_derive/02_apps.md")]
//!
//! You can use `#[clap(author, version, about)]` attribute defaults to fill these fields in from your `Cargo.toml` file.
//! You can use `#[command(author, version, about)]` attribute defaults to fill these fields in from your `Cargo.toml` file.
//!
//! ```rust
#![doc = include_str!("../../examples/tutorial_derive/02_crate.rs")]
@ -88,9 +88,9 @@
//! - They can be optional
//! - Intent is clearer
//!
//! The `#[clap(short = 'n')]` and `#[clap(long = "name")]` attributes that define
//! The `#[arg(short = 'n')]` and `#[arg(long = "name")]` attributes that define
//! the flags are [`Arg`][crate::Args] methods that are derived from the field name when no value
//! is specified (`#[clap(short)]` and `#[clap(long)]`).
//! is specified (`#[arg(short)]` and `#[arg(long)]`).
//!
//! ```rust
#![doc = include_str!("../../examples/tutorial_derive/03_02_option.rs")]
@ -107,7 +107,7 @@
//! ### Flags
//!
//! Flags can also be switches that can be on/off. This is enabled via the
//! `#[clap(action = ArgAction::SetTrue)]` attribute though this is implied when the field is a
//! `#[arg(action = ArgAction::SetTrue)]` attribute though this is implied when the field is a
//! `bool`.
//!
//! ```rust
@ -126,7 +126,7 @@
//!
//! ### Subcommands
//!
//! Subcommands are derived with `#[derive(Subcommand)]` and be added via `#[clap(subcommand)]` attribute. Each
//! Subcommands are derived with `#[derive(Subcommand)]` and be added via `#[command(subcommand)]` attribute. Each
//! instance of a [Subcommand][crate::Subcommand] can have its own version, author(s), Args, and even its own
//! subcommands.
//!
@ -145,7 +145,7 @@
//!
//! We've previously showed that arguments can be [`required`][crate::Arg::required] or optional.
//! When optional, you work with a `Option` and can `unwrap_or`. Alternatively, you can
//! set `#[clap(default_value_t)]`.
//! set `#[arg(default_value_t)]`.
//!
//! ```rust
#![doc = include_str!("../../examples/tutorial_derive/03_05_default_values.rs")]

View file

@ -27,54 +27,54 @@
//!
//! /// Doc comment
//! #[derive(Parser)]
//! #[clap(APP ATTRIBUTE)]
//! #[command(CMD ATTRIBUTE)]
//! struct Cli {
//! /// Doc comment
//! #[clap(ARG ATTRIBUTE)]
//! #[arg(ARG ATTRIBUTE)]
//! field: UserType,
//!
//! #[clap(value_enum, ARG ATTRIBUTE...)]
//! #[arg(value_enum, ARG ATTRIBUTE...)]
//! field: EnumValues,
//!
//! #[clap(flatten)]
//! #[command(flatten)]
//! delegate: Struct,
//!
//! #[clap(subcommand)]
//! #[command(subcommand)]
//! command: Command,
//! }
//!
//! /// Doc comment
//! #[derive(Args)]
//! #[clap(PARENT APP ATTRIBUTE)]
//! #[command(PARENT CMD ATTRIBUTE)]
//! struct Struct {
//! /// Doc comment
//! #[clap(ARG ATTRIBUTE)]
//! #[command(ARG ATTRIBUTE)]
//! field: UserType,
//! }
//!
//! /// Doc comment
//! #[derive(Subcommand)]
//! #[clap(PARENT APP ATTRIBUTE)]
//! #[command(PARENT CMD ATTRIBUTE)]
//! enum Command {
//! /// Doc comment
//! #[clap(APP ATTRIBUTE)]
//! #[command(CMD ATTRIBUTE)]
//! Variant1(Struct),
//!
//! /// Doc comment
//! #[clap(APP ATTRIBUTE)]
//! #[command(CMD ATTRIBUTE)]
//! Variant2 {
//! /// Doc comment
//! #[clap(ARG ATTRIBUTE)]
//! #[arg(ARG ATTRIBUTE)]
//! field: UserType,
//! }
//! }
//!
//! /// Doc comment
//! #[derive(ValueEnum)]
//! #[clap(VALUE ENUM ATTRIBUTE)]
//! #[value(VALUE ENUM ATTRIBUTE)]
//! enum EnumValues {
//! /// Doc comment
//! #[clap(POSSIBLE VALUE ATTRIBUTE)]
//! #[value(POSSIBLE VALUE ATTRIBUTE)]
//! Variant1,
//! }
//!
@ -102,7 +102,7 @@
//!
//! Raw attributes come in two different syntaxes:
//! ```rust,ignore
//! #[clap(
//! #[arg(
//! global = true, // name = arg form, neat for one-arg methods
//! required_if_eq("out", "file") // name(arg1, arg2, ...) form.
//! )]
@ -134,7 +134,7 @@
//!
//! **Raw attributes:** Any [`Command` method][crate::Command] can also be used as an attribute,
//! see [Terminology](#terminology) for syntax.
//! - e.g. `#[clap(arg_required_else_help(true))]` would translate to `cmd.arg_required_else_help(true)`
//! - e.g. `#[command(arg_required_else_help(true))]` would translate to `cmd.arg_required_else_help(true)`
//!
//! **Magic attributes:**
//! - `name = <expr>`: [`Command::name`][crate::Command::name]
@ -149,7 +149,7 @@
//! - When not present: [Doc comment summary](#doc-comments)
//! - Without `<expr>`: [crate `description`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-description-field) ([`Parser`][crate::Parser] container)
//! - **TIP:** When a doc comment is also present, you most likely want to add
//! `#[clap(long_about = None)]` to clear the doc comment so only [`about`][crate::Command::about]
//! `#[arg(long_about = None)]` to clear the doc comment so only [`about`][crate::Command::about]
//! gets shown with both `-h` and `--help`.
//! - `long_about = <expr>`: [`Command::long_about`][crate::Command::long_about]
//! - When not present: [Doc comment](#doc-comments) if there is a blank line, else nothing
@ -178,7 +178,7 @@
//! These correspond to a [`Arg`][crate::Arg].
//!
//! **Raw attributes:** Any [`Arg` method][crate::Arg] can also be used as an attribute, see [Terminology](#terminology) for syntax.
//! - e.g. `#[clap(max_values(3))]` would translate to `arg.max_values(3)`
//! - e.g. `#[arg(max_values(3))]` would translate to `arg.max_values(3)`
//!
//! **Magic attributes**:
//! - `id = <expr>`: [`Arg::id`][crate::Arg::id]
@ -219,16 +219,16 @@
//! - Without `<expr>`: fills the field with `Default::default()`
//! - `default_value = <str>`: [`Arg::default_value`][crate::Arg::default_value] and [`Arg::required(false)`][crate::Arg::required]
//! - `default_value_t [= <expr>]`: [`Arg::default_value`][crate::Arg::default_value] and [`Arg::required(false)`][crate::Arg::required]
//! - Requires `std::fmt::Display` or `#[clap(value_enum)]`
//! - Requires `std::fmt::Display` or `#[arg(value_enum)]`
//! - Without `<expr>`, relies on `Default::default()`
//! - `default_values_t = <expr>`: [`Arg::default_values`][crate::Arg::default_values] and [`Arg::required(false)`][crate::Arg::required]
//! - Requires field arg to be of type `Vec<T>` and `T` to implement `std::fmt::Display` or `#[clap(value_enum)]`
//! - Requires field arg to be of type `Vec<T>` and `T` to implement `std::fmt::Display` or `#[arg(value_enum)]`
//! - `<expr>` must implement `IntoIterator<T>`
//! - `default_value_os_t [= <expr>]`: [`Arg::default_value_os`][crate::Arg::default_value_os] and [`Arg::required(false)`][crate::Arg::required]
//! - Requires `std::convert::Into<OsString>` or `#[clap(value_enum)]`
//! - Requires `std::convert::Into<OsString>` or `#[arg(value_enum)]`
//! - Without `<expr>`, relies on `Default::default()`
//! - `default_values_os_t = <expr>`: [`Arg::default_values_os`][crate::Arg::default_values_os] and [`Arg::required(false)`][crate::Arg::required]
//! - Requires field arg to be of type `Vec<T>` and `T` to implement `std::convert::Into<OsString>` or `#[clap(value_enum)]`
//! - Requires field arg to be of type `Vec<T>` and `T` to implement `std::convert::Into<OsString>` or `#[arg(value_enum)]`
//! - `<expr>` must implement `IntoIterator<T>`
//!
//! ### ValueEnum Attributes
@ -242,7 +242,7 @@
//! These correspond to a [`PossibleValue`][crate::builder::PossibleValue].
//!
//! **Raw attributes:** Any [`PossibleValue` method][crate::builder::PossibleValue] can also be used as an attribute, see [Terminology](#terminology) for syntax.
//! - e.g. `#[clap(alias("foo"))]` would translate to `pv.alias("foo")`
//! - e.g. `#[value(alias("foo"))]` would translate to `pv.alias("foo")`
//!
//! **Magic attributes**:
//! - `name = <expr>`: [`PossibleValue::new`][crate::builder::PossibleValue::new]
@ -282,9 +282,9 @@
//! # use clap::Parser;
//!
//! #[derive(Parser)]
//! #[clap(about = "I am a program and I work, just pass `-h`", long_about = None)]
//! #[command(about = "I am a program and I work, just pass `-h`", long_about = None)]
//! struct Foo {
//! #[clap(short, help = "Pass `-h` and you'll see me!")]
//! #[arg(short, help = "Pass `-h` and you'll see me!")]
//! bar: String,
//! }
//! ```
@ -309,7 +309,7 @@
//! If you really want to use the `Command::about/long_about` methods (you likely don't),
//! use the `about` / `long_about` attributes to override the calls generated from
//! the doc comment. To clear `long_about`, you can use
//! `#[clap(long_about = None)]`.
//! `#[command(long_about = None)]`.
//!
//! **TIP:** Set `#![deny(missing_docs)]` to catch missing `--help` documentation at compile time.
//!
@ -329,7 +329,7 @@
//! /// I am artificial superintelligence. I won't rest
//! /// until I'll have destroyed humanity. Enjoy your
//! /// pathetic existence, you mere mortals.
//! #[clap(long, action)]
//! #[arg(long, action)]
//! kill_all_humans: bool,
//! }
//! ```
@ -380,7 +380,7 @@
//!
//! ### Using derived arguments in a builder application
//!
//! When using the derive API, you can `#[clap(flatten)]` a struct deriving `Args` into a struct
//! When using the derive API, you can `#[command(flatten)]` a struct deriving `Args` into a struct
//! deriving `Args` or `Parser`. This example shows how you can augment a `Command` instance
//! created using the builder API with `Args` created using the derive API.
//!
@ -398,7 +398,7 @@
//!
//! ### Using derived subcommands in a builder application
//!
//! When using the derive API, you can use `#[clap(subcommand)]` inside the struct to add
//! When using the derive API, you can use `#[command(subcommand)]` inside the struct to add
//! subcommands. The type of the field is usually an enum that derived `Parser`. However, you can
//! also add the subcommands in that enum to a `Command` instance created with the builder API.
//!
@ -412,7 +412,7 @@
//!
//! ### Adding hand-implemented subcommands to a derived application
//!
//! When using the derive API, you can use `#[clap(subcommand)]` inside the struct to add
//! When using the derive API, you can use `#[command(subcommand)]` inside the struct to add
//! subcommands. The type of the field is usually an enum that derived `Parser`. However, you can
//! also implement the `Subcommand` trait manually on this enum (or any other type) and it can
//! still be used inside the struct created with the derive API. The implementation of the
@ -423,7 +423,7 @@
//! [`augment_subcommands`][crate::Subcommand::augment_subcommands] on an enum that derived
//! `Parser`, whereas now we implement
//! [`augment_subcommands`][crate::Subcommand::augment_subcommands] ourselves, but the derive API
//! calls it automatically since we used the `#[clap(subcommand)]` attribute.
//! calls it automatically since we used the `#[command(subcommand)]` attribute.
//!
//! For example:
//! ```rust
@ -432,7 +432,7 @@
//!
//! ### Flattening hand-implemented args into a derived application
//!
//! When using the derive API, you can use `#[clap(flatten)]` inside the struct to add arguments as
//! When using the derive API, you can use `#[command(flatten)]` inside the struct to add arguments as
//! if they were added directly to the containing struct. The type of the field is usually an
//! struct that derived `Args`. However, you can also implement the `Args` trait manually on this
//! struct (or any other type) and it can still be used inside the struct created with the derive
@ -442,7 +442,7 @@
//! Notice how in the previous example we used [`augment_args`][crate::Args::augment_args] on the
//! struct that derived `Parser`, whereas now we implement
//! [`augment_args`][crate::Args::augment_args] ourselves, but the derive API calls it
//! automatically since we used the `#[clap(flatten)]` attribute.
//! automatically since we used the `#[command(flatten)]` attribute.
//!
//! For example:
//! ```rust

View file

@ -34,13 +34,13 @@ use std::ffi::OsString;
#[cfg_attr(feature = "derive", doc = " ```")]
/// /// My super CLI
/// #[derive(clap::Parser)]
/// #[clap(name = "demo")]
/// #[command(name = "demo")]
/// struct Context {
/// /// More verbose output
/// #[clap(long)]
/// #[arg(long)]
/// verbose: bool,
/// /// An optional name
/// #[clap(short, long)]
/// #[arg(short, long)]
/// name: Option<String>,
/// }
/// ```
@ -257,7 +257,7 @@ pub trait FromArgMatches: Sized {
///
/// Implementing this trait lets a parent container delegate argument parsing behavior to `Self`.
/// with:
/// - `#[clap(flatten)] args: ChildArgs`: Attribute can only be used with struct fields that impl
/// - `#[command(flatten)] args: ChildArgs`: Attribute can only be used with struct fields that impl
/// `Args`.
/// - `Variant(ChildArgs)`: No attribute is used with enum variants that impl `Args`.
///
@ -271,13 +271,13 @@ pub trait FromArgMatches: Sized {
#[cfg_attr(feature = "derive", doc = " ```")]
/// #[derive(clap::Parser)]
/// struct Args {
/// #[clap(flatten)]
/// #[command(flatten)]
/// logging: LogArgs,
/// }
///
/// #[derive(clap::Args)]
/// struct LogArgs {
/// #[clap(long, short = 'v', action = clap::ArgAction::Count)]
/// #[arg(long, short = 'v', action = clap::ArgAction::Count)]
/// verbose: i8,
/// }
/// ```
@ -288,7 +288,7 @@ pub trait Args: FromArgMatches + Sized {
fn augment_args(cmd: Command) -> Command;
/// Append to [`Command`] so it can update `self`.
///
/// This is used to implement `#[clap(flatten)]`
/// This is used to implement `#[command(flatten)]`
///
/// See also [`CommandFactory`].
fn augment_args_for_update(cmd: Command) -> Command;
@ -298,9 +298,9 @@ pub trait Args: FromArgMatches + Sized {
///
/// Implementing this trait lets a parent container delegate subcommand behavior to `Self`.
/// with:
/// - `#[clap(subcommand)] field: SubCmd`: Attribute can be used with either struct fields or enum
/// - `#[command(subcommand)] field: SubCmd`: Attribute can be used with either struct fields or enum
/// variants that impl `Subcommand`.
/// - `#[clap(flatten)] Variant(SubCmd)`: Attribute can only be used with enum variants that impl
/// - `#[command(flatten)] Variant(SubCmd)`: Attribute can only be used with enum variants that impl
/// `Subcommand`.
///
/// See the [derive reference](crate::_derive) for attributes and best practices.
@ -313,7 +313,7 @@ pub trait Args: FromArgMatches + Sized {
#[cfg_attr(feature = "derive", doc = " ```")]
/// #[derive(clap::Parser)]
/// struct Args {
/// #[clap(subcommand)]
/// #[command(subcommand)]
/// action: Action,
/// }
///
@ -330,7 +330,7 @@ pub trait Subcommand: FromArgMatches + Sized {
fn augment_subcommands(cmd: Command) -> Command;
/// Append to [`Command`] so it can update `self`.
///
/// This is used to implement `#[clap(flatten)]`
/// This is used to implement `#[command(flatten)]`
///
/// See also [`CommandFactory`].
fn augment_subcommands_for_update(cmd: Command) -> Command;
@ -341,9 +341,9 @@ pub trait Subcommand: FromArgMatches + Sized {
/// Parse arguments into enums.
///
/// When deriving [`Parser`], a field whose type implements `ValueEnum` can have the attribute
/// `#[clap(value_enum)]` which will
/// `#[arg(value_enum)]` which will
/// - Call [EnumValueParser`][crate::builder::EnumValueParser]`
/// - Allowing using the `#[clap(default_value_t)]` attribute without implementing `Display`.
/// - Allowing using the `#[arg(default_value_t)]` attribute without implementing `Display`.
///
/// See the [derive reference](crate::_derive) for attributes and best practices.
///
@ -355,7 +355,7 @@ pub trait Subcommand: FromArgMatches + Sized {
#[cfg_attr(feature = "derive", doc = " ```")]
/// #[derive(clap::Parser)]
/// struct Args {
/// #[clap(value_enum)]
/// #[arg(value_enum)]
/// level: Level,
/// }
///

View file

@ -3,7 +3,7 @@ use clap::Parser;
#[test]
fn app_name_in_short_help_from_struct() {
#[derive(Parser)]
#[clap(name = "my-cmd")]
#[command(name = "my-cmd")]
struct MyApp {}
let mut help = Vec::new();
@ -16,7 +16,7 @@ fn app_name_in_short_help_from_struct() {
#[test]
fn app_name_in_long_help_from_struct() {
#[derive(Parser)]
#[clap(name = "my-cmd")]
#[command(name = "my-cmd")]
struct MyApp {}
let mut help = Vec::new();
@ -29,7 +29,7 @@ fn app_name_in_long_help_from_struct() {
#[test]
fn app_name_in_short_help_from_enum() {
#[derive(Parser)]
#[clap(name = "my-cmd")]
#[command(name = "my-cmd")]
enum MyApp {}
let mut help = Vec::new();
@ -42,7 +42,7 @@ fn app_name_in_short_help_from_enum() {
#[test]
fn app_name_in_long_help_from_enum() {
#[derive(Parser)]
#[clap(name = "my-cmd")]
#[command(name = "my-cmd")]
enum MyApp {}
let mut help = Vec::new();
@ -55,7 +55,7 @@ fn app_name_in_long_help_from_enum() {
#[test]
fn app_name_in_short_version_from_struct() {
#[derive(Parser)]
#[clap(name = "my-cmd")]
#[command(name = "my-cmd")]
struct MyApp {}
let version = MyApp::command().render_version();
@ -66,7 +66,7 @@ fn app_name_in_short_version_from_struct() {
#[test]
fn app_name_in_long_version_from_struct() {
#[derive(Parser)]
#[clap(name = "my-cmd")]
#[command(name = "my-cmd")]
struct MyApp {}
let version = MyApp::command().render_long_version();
@ -77,7 +77,7 @@ fn app_name_in_long_version_from_struct() {
#[test]
fn app_name_in_short_version_from_enum() {
#[derive(Parser)]
#[clap(name = "my-cmd")]
#[command(name = "my-cmd")]
enum MyApp {}
let version = MyApp::command().render_version();
@ -88,7 +88,7 @@ fn app_name_in_short_version_from_enum() {
#[test]
fn app_name_in_long_version_from_enum() {
#[derive(Parser)]
#[clap(name = "my-cmd")]
#[command(name = "my-cmd")]
enum MyApp {}
let version = MyApp::command().render_long_version();

View file

@ -33,7 +33,7 @@ fn required_argument() {
fn argument_with_default() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(default_value = "42")]
#[arg(default_value = "42")]
arg: i32,
}
assert_eq!(
@ -67,7 +67,7 @@ fn auto_value_name() {
fn explicit_value_name() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_name = "BROWNIE_POINTS")]
#[arg(value_name = "BROWNIE_POINTS")]
my_special_arg: i32,
}

View file

@ -19,8 +19,8 @@ use clap::Parser;
#[test]
fn no_author_version_about() {
#[derive(Parser, PartialEq, Debug)]
#[clap(name = "foo")]
#[clap(help_template = utils::FULL_TEMPLATE)]
#[command(name = "foo")]
#[command(help_template = utils::FULL_TEMPLATE)]
struct Opt {}
let output = utils::get_long_help::<Opt>();
@ -30,8 +30,8 @@ fn no_author_version_about() {
#[test]
fn use_env() {
#[derive(Parser, PartialEq, Debug)]
#[clap(author, about, version)]
#[clap(help_template = utils::FULL_TEMPLATE)]
#[command(author, about, version)]
#[command(help_template = utils::FULL_TEMPLATE)]
struct Opt {}
let output = utils::get_long_help::<Opt>();
@ -45,8 +45,8 @@ fn explicit_version_not_str_lit() {
const VERSION: &str = "custom version";
#[derive(Parser)]
#[clap(version = VERSION)]
#[clap(help_template = utils::FULL_TEMPLATE)]
#[command(version = VERSION)]
#[command(help_template = utils::FULL_TEMPLATE)]
pub struct Opt {}
let output = utils::get_long_help::<Opt>();

View file

@ -18,7 +18,7 @@ use clap::Parser;
fn basic() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short = 'a', long = "arg")]
#[arg(short = 'a', long = "arg")]
arg: i32,
}
assert_eq!(
@ -31,7 +31,7 @@ fn basic() {
fn update_basic() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short = 'a', long = "arg")]
#[arg(short = 'a', long = "arg")]
single_value: i32,
}

View file

@ -2,14 +2,14 @@ use clap::{Args, Parser, Subcommand};
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(subcommand)]
#[command(subcommand)]
sub: Box<Sub>,
}
#[derive(Subcommand, PartialEq, Debug)]
enum Sub {
Flame {
#[clap(flatten)]
#[command(flatten)]
arg: Box<Ext>,
},
}

View file

@ -19,19 +19,19 @@ use std::path::PathBuf;
#[derive(Parser, PartialEq, Debug)]
struct PathOpt {
#[clap(short, long)]
#[arg(short, long)]
path: PathBuf,
#[clap(short, default_value = "../")]
#[arg(short, default_value = "../")]
default_path: PathBuf,
#[clap(short)]
#[arg(short)]
vector_path: Vec<PathBuf>,
#[clap(short)]
#[arg(short)]
option_path_1: Option<PathBuf>,
#[clap(short = 'q')]
#[arg(short = 'q')]
option_path_2: Option<PathBuf>,
}
@ -63,7 +63,7 @@ fn parse_hex(input: &str) -> Result<u64, ParseIntError> {
#[derive(Parser, PartialEq, Debug)]
struct HexOpt {
#[clap(short, value_parser = parse_hex)]
#[arg(short, value_parser = parse_hex)]
number: u64,
}
@ -102,7 +102,7 @@ fn custom_parser_2(_: &str) -> Result<&'static str, ErrCode> {
#[derive(Parser, PartialEq, Debug)]
struct NoOpOpt {
#[clap(short, value_parser = custom_parser_2)]
#[arg(short, value_parser = custom_parser_2)]
b: &'static str,
}
@ -125,10 +125,10 @@ fn update_every_custom_parser() {
#[derive(Parser, PartialEq, Debug)]
struct DefaultedOpt {
#[clap(short)]
#[arg(short)]
integer: u64,
#[clap(short)]
#[arg(short)]
path: PathBuf,
}

View file

@ -8,7 +8,7 @@ use crate::utils;
fn default_value() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(default_value = "3")]
#[arg(default_value = "3")]
arg: i32,
}
assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap());
@ -22,7 +22,7 @@ fn default_value() {
fn default_value_t() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(default_value_t = 3)]
#[arg(default_value_t = 3)]
arg: i32,
}
assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap());
@ -36,7 +36,7 @@ fn default_value_t() {
fn auto_default_value_t() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(default_value_t)]
#[arg(default_value_t)]
arg: i32,
}
assert_eq!(Opt { arg: 0 }, Opt::try_parse_from(&["test"]).unwrap());
@ -50,22 +50,22 @@ fn auto_default_value_t() {
fn default_values_t() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(default_values_t = vec![1, 2, 3])]
#[arg(default_values_t = vec![1, 2, 3])]
arg1: Vec<i32>,
#[clap(long, default_values_t = &[4, 5, 6])]
#[arg(long, default_values_t = &[4, 5, 6])]
arg2: Vec<i32>,
#[clap(long, default_values_t = [7, 8, 9])]
#[arg(long, default_values_t = [7, 8, 9])]
arg3: Vec<i32>,
#[clap(long, default_values_t = 10..=12)]
#[arg(long, default_values_t = 10..=12)]
arg4: Vec<i32>,
#[clap(long, default_values_t = vec!["hello".to_string(), "world".to_string()])]
#[arg(long, default_values_t = vec!["hello".to_string(), "world".to_string()])]
arg5: Vec<String>,
#[clap(long, default_values_t = &vec!["foo".to_string(), "bar".to_string()])]
#[arg(long, default_values_t = &vec!["foo".to_string(), "bar".to_string()])]
arg6: Vec<String>,
}
assert_eq!(
@ -110,7 +110,7 @@ fn default_values_t() {
fn default_value_os_t() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(default_value_os_t = PathBuf::from("abc.def"))]
#[arg(default_value_os_t = PathBuf::from("abc.def"))]
arg: PathBuf,
}
assert_eq!(
@ -134,12 +134,12 @@ fn default_value_os_t() {
fn default_values_os_t() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(
#[arg(
default_values_os_t = vec![PathBuf::from("abc.def"), PathBuf::from("123.foo")]
)]
arg1: Vec<PathBuf>,
#[clap(
#[arg(
long,
default_values_os_t = &[PathBuf::from("bar.baz")]
)]
@ -170,7 +170,7 @@ fn detect_os_variant() {
#[derive(clap::Parser)]
pub struct Options {
#[clap(default_value_os = "123")]
#[arg(default_value_os = "123")]
x: String,
}
Options::command().debug_assert();

View file

@ -24,7 +24,7 @@ fn try_str(s: &str) -> Result<String, std::convert::Infallible> {
fn warning_never_struct() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(value_parser = try_str, default_value_t)]
#[arg(value_parser = try_str, default_value_t)]
s: String,
}
assert_eq!(
@ -40,7 +40,7 @@ fn warning_never_enum() {
#[derive(Parser, Debug, PartialEq)]
enum Opt {
Foo {
#[clap(value_parser = try_str, default_value_t)]
#[arg(value_parser = try_str, default_value_t)]
s: String,
},
}

View file

@ -23,7 +23,7 @@ fn doc_comments() {
struct LoremIpsum {
/// Fooify a bar
/// and a baz
#[clap(short, long)]
#[arg(short, long)]
foo: bool,
}
@ -36,10 +36,10 @@ fn doc_comments() {
fn help_is_better_than_comments() {
/// Lorem ipsum
#[derive(Parser, PartialEq, Debug)]
#[clap(name = "lorem-ipsum", about = "Dolor sit amet")]
#[command(name = "lorem-ipsum", about = "Dolor sit amet")]
struct LoremIpsum {
/// Fooify a bar
#[clap(short, long, help = "DO NOT PASS A BAR UNDER ANY CIRCUMSTANCES")]
#[arg(short, long, help = "DO NOT PASS A BAR UNDER ANY CIRCUMSTANCES")]
foo: bool,
}
@ -55,7 +55,7 @@ fn empty_line_in_doc_comment_is_double_linefeed() {
///
/// Bar
#[derive(Parser, PartialEq, Debug)]
#[clap(name = "lorem-ipsum")]
#[command(name = "lorem-ipsum")]
struct LoremIpsum {}
let help = utils::get_long_help::<LoremIpsum>();
@ -73,16 +73,16 @@ Usage:"
fn field_long_doc_comment_both_help_long_help() {
/// Lorem ipsumclap
#[derive(Parser, PartialEq, Debug)]
#[clap(name = "lorem-ipsum", about = "Dolor sit amet")]
#[command(name = "lorem-ipsum", about = "Dolor sit amet")]
struct LoremIpsum {
/// Dot is removed from multiline comments.
///
/// Long help
#[clap(long)]
#[arg(long)]
foo: bool,
/// Dot is removed from one short comment.
#[clap(long)]
#[arg(long)]
bar: bool,
}
@ -101,9 +101,9 @@ fn field_long_doc_comment_both_help_long_help() {
fn top_long_doc_comment_both_help_long_help() {
/// Lorem ipsumclap
#[derive(Parser, Debug)]
#[clap(name = "lorem-ipsum", about = "Dolor sit amet")]
#[command(name = "lorem-ipsum", about = "Dolor sit amet")]
struct LoremIpsum {
#[clap(subcommand)]
#[command(subcommand)]
foo: SubCommand,
}
@ -113,7 +113,7 @@ fn top_long_doc_comment_both_help_long_help() {
///
/// Or something else
Foo {
#[clap(help = "foo")]
#[arg(help = "foo")]
bars: String,
},
}
@ -146,9 +146,9 @@ fn verbatim_doc_comment() {
/// ( () ||
/// ( () ) )
#[derive(Parser, Debug)]
#[clap(verbatim_doc_comment)]
#[command(verbatim_doc_comment)]
struct SeeFigure1 {
#[clap(long)]
#[arg(long)]
foo: bool,
}
@ -178,10 +178,10 @@ fn verbatim_doc_comment_field() {
#[derive(Parser, Debug)]
struct Command {
/// This help ends in a period.
#[clap(long, verbatim_doc_comment)]
#[arg(long, verbatim_doc_comment)]
foo: bool,
/// This help does not end in a period.
#[clap(long)]
#[arg(long)]
bar: bool,
}
@ -198,7 +198,7 @@ fn multiline_separates_default() {
/// Multiline
///
/// Doc comment
#[clap(long, default_value = "x")]
#[arg(long, default_value = "x")]
x: String,
}
@ -227,7 +227,7 @@ fn doc_comment_about_handles_both_abouts() {
/// Opts doc comment summary
#[derive(Parser, Debug)]
pub struct Opts {
#[clap(subcommand)]
#[command(subcommand)]
pub cmd: Sub,
}

View file

@ -6,7 +6,7 @@ use clap::Parser;
fn explicit_short_long_no_rename() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short = '.', long = ".foo")]
#[arg(short = '.', long = ".foo")]
foo: String,
}
@ -27,7 +27,7 @@ fn explicit_short_long_no_rename() {
fn explicit_name_no_rename() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(name = ".options")]
#[arg(name = ".options")]
foo: String,
}

View file

@ -22,7 +22,7 @@ use clap::Parser;
fn bool_type_is_flag() {
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(short, long)]
#[arg(short, long)]
alice: bool,
}
@ -58,9 +58,9 @@ fn non_bool_type_flag() {
#[derive(Parser, Debug)]
struct Opt {
#[clap(short, long, action = ArgAction::SetTrue, value_parser = BoolishValueParser::new().map(parse_from_flag))]
#[arg(short, long, action = ArgAction::SetTrue, value_parser = BoolishValueParser::new().map(parse_from_flag))]
alice: usize,
#[clap(short, long, action = ArgAction::SetTrue, value_parser = BoolishValueParser::new().map(parse_from_flag))]
#[arg(short, long, action = ArgAction::SetTrue, value_parser = BoolishValueParser::new().map(parse_from_flag))]
bob: usize,
}
@ -87,7 +87,7 @@ fn inferred_help() {
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
/// Foo
#[clap(short, long)]
#[arg(short, long)]
help: bool,
}
@ -108,7 +108,7 @@ fn inferred_version() {
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
/// Foo
#[clap(short, long)]
#[arg(short, long)]
version: bool,
}
@ -130,9 +130,9 @@ fn inferred_version() {
fn count() {
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(short, long, action = clap::ArgAction::Count)]
#[arg(short, long, action = clap::ArgAction::Count)]
alice: u8,
#[clap(short, long, action = clap::ArgAction::Count)]
#[arg(short, long, action = clap::ArgAction::Count)]
bob: u8,
}
@ -164,9 +164,9 @@ fn count() {
fn mixed_type_flags() {
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(short, long)]
#[arg(short, long)]
alice: bool,
#[clap(short, long, action = clap::ArgAction::Count)]
#[arg(short, long, action = clap::ArgAction::Count)]
bob: u8,
}
@ -247,7 +247,7 @@ fn ignore_qualified_bool_type() {
fn override_implicit_action() {
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(long, action = clap::ArgAction::Set)]
#[arg(long, action = clap::ArgAction::Set)]
arg: bool,
}
@ -266,7 +266,7 @@ fn override_implicit_action() {
fn override_implicit_from_flag_positional() {
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(action = clap::ArgAction::Set)]
#[arg(action = clap::ArgAction::Set)]
arg: bool,
}

View file

@ -25,7 +25,7 @@ fn flatten() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(flatten)]
#[command(flatten)]
common: Common,
}
assert_eq!(
@ -49,10 +49,10 @@ fn flatten_twice() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(flatten)]
#[command(flatten)]
c1: Common,
// Defines "arg" twice, so this should not work.
#[clap(flatten)]
#[command(flatten)]
c2: Common,
}
Opt::try_parse_from(&["test", "42", "43"]).unwrap();
@ -67,18 +67,18 @@ fn flatten_in_subcommand() {
#[derive(Args, PartialEq, Debug)]
struct Add {
#[clap(short)]
#[arg(short)]
interactive: bool,
#[clap(flatten)]
#[command(flatten)]
common: Common,
}
#[derive(Parser, PartialEq, Debug)]
enum Opt {
Fetch {
#[clap(short)]
#[arg(short)]
all: bool,
#[clap(flatten)]
#[command(flatten)]
common: Common,
},
@ -110,7 +110,7 @@ fn update_args_with_flatten() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(flatten)]
#[command(flatten)]
common: Common,
}
@ -146,7 +146,7 @@ struct Command2 {
#[derive(Parser, PartialEq, Debug)]
enum Opt {
#[clap(flatten)]
#[command(flatten)]
BaseCli(BaseCli),
Command2(Command2),
}
@ -200,7 +200,7 @@ fn flatten_with_doc_comment() {
struct Opt {
/// The very important comment that clippy had me put here.
/// It knows better.
#[clap(flatten)]
#[command(flatten)]
common: Common,
}
assert_eq!(
@ -216,18 +216,18 @@ fn flatten_with_doc_comment() {
}
#[test]
fn docstrings_ordering_with_multiple_clap() {
fn docstrings_ordering_with_multiple_command() {
/// This is the docstring for Flattened
#[derive(Args)]
struct Flattened {
#[clap(long)]
#[arg(long)]
foo: bool,
}
/// This is the docstring for Command
#[derive(Parser)]
struct Command {
#[clap(flatten)]
#[command(flatten)]
flattened: Flattened,
}
@ -241,13 +241,13 @@ fn docstrings_ordering_with_multiple_clap_partial() {
/// This is the docstring for Flattened
#[derive(Args)]
struct Flattened {
#[clap(long)]
#[arg(long)]
foo: bool,
}
#[derive(Parser)]
struct Command {
#[clap(flatten)]
#[command(flatten)]
flattened: Flattened,
}

View file

@ -9,7 +9,7 @@ fn generic_struct_flatten() {
#[derive(Parser, PartialEq, Debug)]
struct Outer<T: Args> {
#[clap(flatten)]
#[command(flatten)]
pub inner: T,
}
@ -33,7 +33,7 @@ fn generic_struct_flatten_w_where_clause() {
where
T: Args,
{
#[clap(flatten)]
#[command(flatten)]
pub inner: T,
}
@ -112,7 +112,7 @@ fn generic_wo_trait_bound() {
#[derive(Parser, PartialEq, Debug)]
struct Opt<T> {
answer: isize,
#[clap(skip)]
#[arg(skip)]
took: Option<T>,
}

View file

@ -4,11 +4,11 @@ use clap::{ArgAction, Args, CommandFactory, Parser, Subcommand};
fn arg_help_heading_applied() {
#[derive(Debug, Clone, Parser)]
struct CliOptions {
#[clap(long)]
#[clap(help_heading = Some("HEADING A"))]
#[arg(long)]
#[arg(help_heading = Some("HEADING A"))]
should_be_in_section_a: u32,
#[clap(long)]
#[arg(long)]
no_section: u32,
}
@ -30,13 +30,13 @@ fn arg_help_heading_applied() {
#[test]
fn app_help_heading_applied() {
#[derive(Debug, Clone, Parser)]
#[clap(next_help_heading = "DEFAULT")]
#[command(next_help_heading = "DEFAULT")]
struct CliOptions {
#[clap(long)]
#[clap(help_heading = Some("HEADING A"))]
#[arg(long)]
#[arg(help_heading = Some("HEADING A"))]
should_be_in_section_a: u32,
#[clap(long)]
#[arg(long)]
should_be_in_default_section: u32,
}
@ -65,41 +65,41 @@ fn app_help_heading_flattened() {
#[derive(Debug, Clone, Parser)]
struct CliOptions {
#[clap(flatten)]
#[command(flatten)]
options_a: OptionsA,
#[clap(flatten)]
#[command(flatten)]
options_b: OptionsB,
#[clap(subcommand)]
#[command(subcommand)]
sub_a: SubA,
#[clap(long)]
#[arg(long)]
should_be_in_default_section: u32,
}
#[derive(Debug, Clone, Args)]
#[clap(next_help_heading = "HEADING A")]
#[command(next_help_heading = "HEADING A")]
struct OptionsA {
#[clap(long)]
#[arg(long)]
should_be_in_section_a: u32,
}
#[derive(Debug, Clone, Args)]
#[clap(next_help_heading = "HEADING B")]
#[command(next_help_heading = "HEADING B")]
struct OptionsB {
#[clap(long)]
#[arg(long)]
should_be_in_section_b: u32,
}
#[derive(Debug, Clone, Subcommand)]
enum SubA {
#[clap(flatten)]
#[command(flatten)]
SubB(SubB),
#[clap(subcommand)]
#[command(subcommand)]
SubC(SubC),
SubAOne,
#[clap(next_help_heading = "SUB A")]
#[command(next_help_heading = "SUB A")]
SubATwo {
should_be_in_sub_a: u32,
},
@ -107,13 +107,13 @@ fn app_help_heading_flattened() {
#[derive(Debug, Clone, Subcommand)]
enum SubB {
#[clap(next_help_heading = "SUB B")]
#[command(next_help_heading = "SUB B")]
SubBOne { should_be_in_sub_b: u32 },
}
#[derive(Debug, Clone, Subcommand)]
enum SubC {
#[clap(next_help_heading = "SUB C")]
#[command(next_help_heading = "SUB C")]
SubCOne { should_be_in_sub_c: u32 },
}
@ -167,14 +167,14 @@ fn app_help_heading_flattened() {
fn flatten_field_with_help_heading() {
#[derive(Debug, Clone, Parser)]
struct CliOptions {
#[clap(flatten)]
#[clap(next_help_heading = "HEADING A")]
#[command(flatten)]
#[command(next_help_heading = "HEADING A")]
options_a: OptionsA,
}
#[derive(Debug, Clone, Args)]
struct OptionsA {
#[clap(long)]
#[arg(long)]
should_be_in_section_a: u32,
}
@ -194,19 +194,19 @@ fn flatten_field_with_help_heading() {
#[test]
fn derive_generated_error_has_full_context() {
#[derive(Debug, Parser)]
#[clap(subcommand_negates_reqs = true)]
#[command(subcommand_negates_reqs = true)]
struct Opts {
#[clap(long)]
#[arg(long)]
req_str: String,
#[clap(subcommand)]
#[command(subcommand)]
cmd: Option<SubCommands>,
}
#[derive(Debug, Parser)]
enum SubCommands {
Sub {
#[clap(short, long, action = clap::ArgAction::Count)]
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
},
}
@ -245,33 +245,33 @@ Options:
";
#[derive(Parser, Debug)]
#[clap(name = "test", version = "1.2")]
#[command(name = "test", version = "1.2")]
struct Args {
#[clap(flatten)]
#[command(flatten)]
a: A,
#[clap(flatten)]
#[command(flatten)]
b: B,
}
#[derive(Args, Debug)]
#[clap(next_display_order = 10000)]
#[command(next_display_order = 10000)]
struct A {
/// second flag
#[clap(long)]
#[arg(long)]
flag_a: bool,
/// second option
#[clap(long)]
#[arg(long)]
option_a: Option<String>,
}
#[derive(Args, Debug)]
#[clap(next_display_order = 10)]
#[command(next_display_order = 10)]
struct B {
/// first flag
#[clap(long)]
#[arg(long)]
flag_b: bool,
/// first option
#[clap(long)]
#[arg(long)]
option_b: Option<String>,
}
@ -300,33 +300,33 @@ Options:
";
#[derive(Parser, Debug)]
#[clap(name = "test", version = "1.2")]
#[command(name = "test", version = "1.2")]
struct Args {
#[clap(flatten)]
#[clap(next_display_order = 10000)]
#[command(flatten)]
#[command(next_display_order = 10000)]
a: A,
#[clap(flatten)]
#[clap(next_display_order = 10)]
#[command(flatten)]
#[command(next_display_order = 10)]
b: B,
}
#[derive(Args, Debug)]
struct A {
/// second flag
#[clap(long)]
#[arg(long)]
flag_a: bool,
/// second option
#[clap(long)]
#[arg(long)]
option_a: Option<String>,
}
#[derive(Args, Debug)]
struct B {
/// first flag
#[clap(long)]
#[arg(long)]
flag_b: bool,
/// first option
#[clap(long)]
#[arg(long)]
option_b: Option<String>,
}
@ -355,32 +355,32 @@ Options:
";
#[derive(Parser, Debug)]
#[clap(name = "test", version = "1.2")]
#[clap(next_display_order = None)]
#[command(name = "test", version = "1.2")]
#[command(next_display_order = None)]
struct Args {
#[clap(flatten)]
#[command(flatten)]
a: A,
#[clap(flatten)]
#[command(flatten)]
b: B,
}
#[derive(Args, Debug)]
struct A {
/// first flag
#[clap(long)]
#[arg(long)]
flag_a: bool,
/// first option
#[clap(long)]
#[arg(long)]
option_a: Option<String>,
}
#[derive(Args, Debug)]
struct B {
/// second flag
#[clap(long)]
#[arg(long)]
flag_b: bool,
/// second option
#[clap(long)]
#[arg(long)]
option_b: Option<String>,
}
@ -418,7 +418,7 @@ Options:
#[derive(Parser, PartialEq, Debug)]
struct Args {
/// Argument help
#[clap(value_enum)]
#[arg(value_enum)]
arg: ArgChoice,
}
@ -442,9 +442,9 @@ Options:
#[test]
fn custom_help_flag() {
#[derive(Debug, Clone, Parser)]
#[clap(disable_help_flag = true)]
#[command(disable_help_flag = true)]
struct CliOptions {
#[clap(short = 'h', long = "verbose-help", action = ArgAction::Help)]
#[arg(short = 'h', long = "verbose-help", action = ArgAction::Help)]
help: bool,
}
@ -456,9 +456,9 @@ fn custom_help_flag() {
#[test]
fn custom_version_flag() {
#[derive(Debug, Clone, Parser)]
#[clap(disable_version_flag = true, version = "2.0.0")]
#[command(disable_version_flag = true, version = "2.0.0")]
struct CliOptions {
#[clap(short = 'V', long = "verbose-version", action = ArgAction::Version)]
#[arg(short = 'V', long = "verbose-version", action = ArgAction::Version)]
version: bool,
}

View file

@ -7,17 +7,17 @@ use clap::{ArgGroup, Args, Parser, Subcommand};
#[test]
fn issue_151_groups_within_subcommands() {
#[derive(Args, Debug)]
#[clap(group = ArgGroup::new("verb").required(true).multiple(true))]
#[command(group = ArgGroup::new("verb").required(true).multiple(true))]
struct Opt {
#[clap(long, group = "verb")]
#[arg(long, group = "verb")]
foo: Option<String>,
#[clap(long, group = "verb")]
#[arg(long, group = "verb")]
bar: Option<String>,
}
#[derive(Debug, Parser)]
struct Cli {
#[clap(flatten)]
#[command(flatten)]
a: Opt,
}
@ -31,17 +31,17 @@ fn issue_151_groups_within_subcommands() {
#[test]
fn issue_289() {
#[derive(Parser)]
#[clap(infer_subcommands = true)]
#[command(infer_subcommands = true)]
enum Args {
SomeCommand {
#[clap(subcommand)]
#[command(subcommand)]
sub: SubSubCommand,
},
AnotherCommand,
}
#[derive(Subcommand)]
#[clap(infer_subcommands = true)]
#[command(infer_subcommands = true)]
enum SubSubCommand {
TestCommand,
}
@ -59,10 +59,10 @@ fn issue_324() {
}
#[derive(Parser)]
#[clap(version = my_version())]
#[clap(help_template = utils::FULL_TEMPLATE)]
#[command(version = my_version())]
#[command(help_template = utils::FULL_TEMPLATE)]
struct Opt {
#[clap(subcommand)]
#[command(subcommand)]
_cmd: SubCommand,
}
@ -79,7 +79,7 @@ fn issue_324() {
fn issue_418() {
#[derive(Debug, Parser)]
struct Opts {
#[clap(subcommand)]
#[command(subcommand)]
/// The command to run
command: Command,
}
@ -87,13 +87,13 @@ fn issue_418() {
#[derive(Debug, Subcommand)]
enum Command {
/// Reticulate the splines
#[clap(visible_alias = "ret")]
#[command(visible_alias = "ret")]
Reticulate {
/// How many splines
num_splines: u8,
},
/// Frobnicate the rest
#[clap(visible_alias = "frob")]
#[command(visible_alias = "frob")]
Frobnicate,
}
@ -123,7 +123,7 @@ fn issue_490() {
#[derive(Parser, Debug)]
struct Opt {
opt_vec: Vec<u16>,
#[clap(long)]
#[arg(long)]
opt_opt_vec: Option<Vec<u16>>,
}

View file

@ -22,7 +22,7 @@ fn use_option() {
($name:ident: $ty:ty) => {
#[derive(Parser)]
struct Outer {
#[clap(short, long)]
#[arg(short, long)]
#[allow(dead_code)]
$name: $ty,
}
@ -47,7 +47,7 @@ fn issue_447() {
}
Command! {GitCmd, [
#[clap(external_subcommand)]
#[command(external_subcommand)]
Ext(Vec<String>)
]}
}

View file

@ -5,7 +5,7 @@ fn test_standalone_long_generates_kebab_case() {
#[derive(Parser, Debug, PartialEq)]
#[allow(non_snake_case)]
struct Opt {
#[clap(long)]
#[arg(long)]
FOO_OPTION: bool,
}
@ -19,7 +19,7 @@ fn test_standalone_long_generates_kebab_case() {
fn test_custom_long_overwrites_default_name() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(long = "foo")]
#[arg(long = "foo")]
foo_option: bool,
}
@ -33,7 +33,7 @@ fn test_custom_long_overwrites_default_name() {
fn test_standalone_long_uses_previous_defined_custom_name() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(name = "foo", long)]
#[arg(name = "foo", long)]
foo_option: bool,
}
@ -47,7 +47,7 @@ fn test_standalone_long_uses_previous_defined_custom_name() {
fn test_standalone_long_ignores_afterwards_defined_custom_name() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(long, name = "foo")]
#[arg(long, name = "foo")]
foo_option: bool,
}
@ -61,7 +61,7 @@ fn test_standalone_long_ignores_afterwards_defined_custom_name() {
fn test_standalone_long_uses_previous_defined_custom_id() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(id = "foo", long)]
#[arg(id = "foo", long)]
foo_option: bool,
}
@ -75,7 +75,7 @@ fn test_standalone_long_uses_previous_defined_custom_id() {
fn test_standalone_long_ignores_afterwards_defined_custom_id() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(long, id = "foo")]
#[arg(long, id = "foo")]
foo_option: bool,
}
@ -90,7 +90,7 @@ fn test_standalone_short_generates_kebab_case() {
#[derive(Parser, Debug, PartialEq)]
#[allow(non_snake_case)]
struct Opt {
#[clap(short)]
#[arg(short)]
FOO_OPTION: bool,
}
@ -104,7 +104,7 @@ fn test_standalone_short_generates_kebab_case() {
fn test_custom_short_overwrites_default_name() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(short = 'o')]
#[arg(short = 'o')]
foo_option: bool,
}
@ -118,7 +118,7 @@ fn test_custom_short_overwrites_default_name() {
fn test_standalone_short_uses_previous_defined_custom_name() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(name = "option", short)]
#[arg(name = "option", short)]
foo_option: bool,
}
@ -132,7 +132,7 @@ fn test_standalone_short_uses_previous_defined_custom_name() {
fn test_standalone_short_ignores_afterwards_defined_custom_name() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(short, name = "option")]
#[arg(short, name = "option")]
foo_option: bool,
}
@ -146,7 +146,7 @@ fn test_standalone_short_ignores_afterwards_defined_custom_name() {
fn test_standalone_short_uses_previous_defined_custom_id() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(id = "option", short)]
#[arg(id = "option", short)]
foo_option: bool,
}
@ -160,7 +160,7 @@ fn test_standalone_short_uses_previous_defined_custom_id() {
fn test_standalone_short_ignores_afterwards_defined_custom_id() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(short, id = "option")]
#[arg(short, id = "option")]
foo_option: bool,
}
@ -174,7 +174,7 @@ fn test_standalone_short_ignores_afterwards_defined_custom_id() {
fn test_standalone_long_uses_previous_defined_casing() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(rename_all = "screaming_snake", long)]
#[arg(rename_all = "screaming_snake", long)]
foo_option: bool,
}
@ -188,7 +188,7 @@ fn test_standalone_long_uses_previous_defined_casing() {
fn test_standalone_short_uses_previous_defined_casing() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(rename_all = "screaming_snake", short)]
#[arg(rename_all = "screaming_snake", short)]
foo_option: bool,
}
@ -203,7 +203,7 @@ fn test_standalone_long_works_with_verbatim_casing() {
#[derive(Parser, Debug, PartialEq)]
#[allow(non_snake_case)]
struct Opt {
#[clap(rename_all = "verbatim", long)]
#[arg(rename_all = "verbatim", long)]
_fOO_oPtiON: bool,
}
@ -217,7 +217,7 @@ fn test_standalone_long_works_with_verbatim_casing() {
fn test_standalone_short_works_with_verbatim_casing() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(rename_all = "verbatim", short)]
#[arg(rename_all = "verbatim", short)]
_foo: bool,
}
@ -230,9 +230,9 @@ fn test_standalone_short_works_with_verbatim_casing() {
#[test]
fn test_rename_all_is_propagated_from_struct_to_fields() {
#[derive(Parser, Debug, PartialEq)]
#[clap(rename_all = "screaming_snake")]
#[command(rename_all = "screaming_snake")]
struct Opt {
#[clap(long)]
#[arg(long)]
foo: bool,
}
@ -245,15 +245,15 @@ fn test_rename_all_is_propagated_from_struct_to_fields() {
#[test]
fn test_rename_all_is_not_propagated_from_struct_into_flattened() {
#[derive(Parser, Debug, PartialEq)]
#[clap(rename_all = "screaming_snake")]
#[command(rename_all = "screaming_snake")]
struct Opt {
#[clap(flatten)]
#[command(flatten)]
foo: Foo,
}
#[derive(Parser, Debug, PartialEq)]
struct Foo {
#[clap(long)]
#[arg(long)]
foo: bool,
}
@ -269,7 +269,7 @@ fn test_rename_all_is_not_propagated_from_struct_into_flattened() {
fn test_lower_is_renamed() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(rename_all = "lower", long)]
#[arg(rename_all = "lower", long)]
foo_option: bool,
}
@ -283,7 +283,7 @@ fn test_lower_is_renamed() {
fn test_upper_is_renamed() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(rename_all = "upper", long)]
#[arg(rename_all = "upper", long)]
foo_option: bool,
}
@ -322,16 +322,16 @@ fn test_multi_word_enum_variant_is_renamed() {
#[test]
fn test_rename_all_is_not_propagated_from_struct_into_subcommand() {
#[derive(Parser, Debug, PartialEq)]
#[clap(rename_all = "screaming_snake")]
#[command(rename_all = "screaming_snake")]
struct Opt {
#[clap(subcommand)]
#[command(subcommand)]
foo: Foo,
}
#[derive(Parser, Debug, PartialEq)]
enum Foo {
Command {
#[clap(long)]
#[arg(long)]
foo: bool,
},
}
@ -347,11 +347,11 @@ fn test_rename_all_is_not_propagated_from_struct_into_subcommand() {
#[test]
fn test_rename_all_is_propagated_from_enum_to_variants() {
#[derive(Parser, Debug, PartialEq)]
#[clap(rename_all = "screaming_snake")]
#[command(rename_all = "screaming_snake")]
enum Opt {
FirstVariant,
SecondVariant {
#[clap(long)]
#[arg(long)]
foo: String,
},
}
@ -365,11 +365,11 @@ fn test_rename_all_is_propagated_from_enum_to_variants() {
#[test]
fn test_rename_all_is_propagated_from_enum_to_variant_fields() {
#[derive(Parser, Debug, PartialEq)]
#[clap(rename_all = "screaming_snake")]
#[command(rename_all = "screaming_snake")]
enum Opt {
FirstVariant,
SecondVariant {
#[clap(long)]
#[arg(long)]
foo: String,
},
}
@ -385,15 +385,15 @@ fn test_rename_all_is_propagated_from_enum_to_variant_fields() {
#[test]
fn test_rename_all_is_propagation_can_be_overridden() {
#[derive(Parser, Debug, PartialEq)]
#[clap(rename_all = "screaming_snake")]
#[command(rename_all = "screaming_snake")]
enum Opt {
#[clap(rename_all = "kebab_case")]
#[command(rename_all = "kebab_case")]
FirstVariant {
#[clap(long)]
#[arg(long)]
foo_option: bool,
},
SecondVariant {
#[clap(rename_all = "kebab_case", long)]
#[arg(rename_all = "kebab_case", long)]
foo_option: bool,
},
}

View file

@ -16,11 +16,11 @@ use clap::{Parser, Subcommand};
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short, long)]
#[arg(short, long)]
force: bool,
#[clap(short, long, action = clap::ArgAction::Count)]
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
#[clap(subcommand)]
#[command(subcommand)]
cmd: Sub,
}
@ -32,11 +32,11 @@ enum Sub {
#[derive(Parser, PartialEq, Debug)]
struct Opt2 {
#[clap(short, long)]
#[arg(short, long)]
force: bool,
#[clap(short, long, action = clap::ArgAction::Count)]
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
#[clap(subcommand)]
#[command(subcommand)]
cmd: Option<Sub>,
}
@ -109,9 +109,9 @@ fn test_badinput() {
#[derive(Parser, PartialEq, Debug)]
struct Opt3 {
#[clap(short, long)]
#[arg(short, long)]
all: bool,
#[clap(subcommand)]
#[command(subcommand)]
cmd: Sub2,
}
@ -119,7 +119,7 @@ struct Opt3 {
enum Sub2 {
Foo {
file: String,
#[clap(subcommand)]
#[command(subcommand)]
cmd: Sub3,
},
Bar {},
@ -148,11 +148,11 @@ fn test_subsubcommand() {
#[derive(Parser, PartialEq, Debug)]
enum SubSubCmdWithOption {
Remote {
#[clap(subcommand)]
#[command(subcommand)]
cmd: Option<Remote>,
},
Stash {
#[clap(subcommand)]
#[command(subcommand)]
cmd: Stash,
},
}

View file

@ -20,9 +20,9 @@ pub const DISPLAY_ORDER: usize = 2;
// Check if the global settings compile
#[derive(Parser, Debug, PartialEq, Eq)]
#[clap(allow_hyphen_values = true)]
#[command(allow_hyphen_values = true)]
struct Opt {
#[clap(
#[arg(
long = "x",
display_order = DISPLAY_ORDER,
next_line_help = true,
@ -31,13 +31,13 @@ struct Opt {
)]
x: i32,
#[clap(short = 'l', long = "level", aliases = ["set-level", "lvl"])]
#[arg(short = 'l', long = "level", aliases = ["set-level", "lvl"])]
level: String,
#[clap(long("values"))]
#[arg(long("values"))]
values: Vec<i32>,
#[clap(name = "FILE", requires_if("FILE", "values"))]
#[arg(name = "FILE", requires_if("FILE", "values"))]
files: Vec<String>,
}
@ -131,7 +131,7 @@ fn parse_hex(input: &str) -> Result<u64, ParseIntError> {
#[derive(Parser, PartialEq, Debug)]
struct HexOpt {
#[clap(short, value_parser = parse_hex)]
#[arg(short, value_parser = parse_hex)]
number: u64,
}

View file

@ -22,7 +22,7 @@ use clap::{Parser, Subcommand};
fn required_option() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short, long)]
#[arg(short, long)]
arg: i32,
}
assert_eq!(
@ -48,7 +48,7 @@ fn required_option() {
fn option_with_default() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short, default_value = "42")]
#[arg(short, default_value = "42")]
arg: i32,
}
assert_eq!(
@ -66,7 +66,7 @@ fn option_with_default() {
fn option_with_raw_default() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short, default_value = "42")]
#[arg(short, default_value = "42")]
arg: i32,
}
assert_eq!(
@ -148,7 +148,7 @@ fn option_vec_from_str() {
#[derive(Debug, Parser, PartialEq)]
struct Opt {
#[clap(short)]
#[arg(short)]
a: Option<Vec<A>>,
}
@ -163,7 +163,7 @@ fn option_vec_from_str() {
fn option_type_is_optional() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short)]
#[arg(short)]
arg: Option<i32>,
}
assert_eq!(
@ -180,19 +180,19 @@ fn option_type_is_optional() {
#[test]
fn required_with_option_type() {
#[derive(Debug, PartialEq, Eq, Parser)]
#[clap(subcommand_negates_reqs = true)]
#[command(subcommand_negates_reqs = true)]
struct Opt {
#[clap(required = true)]
#[arg(required = true)]
req_str: Option<String>,
#[clap(subcommand)]
#[command(subcommand)]
cmd: Option<SubCommands>,
}
#[derive(Debug, PartialEq, Eq, Subcommand)]
enum SubCommands {
ExSub {
#[clap(short, long, action = clap::ArgAction::Count)]
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
},
}
@ -224,7 +224,7 @@ fn ignore_qualified_option_type() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_parser = parser)]
#[arg(value_parser = parser)]
arg: ::std::option::Option<String>,
}
@ -240,7 +240,7 @@ fn ignore_qualified_option_type() {
fn option_option_type_is_optional_value() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short)]
#[arg(short)]
#[allow(clippy::option_option)]
arg: Option<Option<i32>>,
}
@ -267,7 +267,7 @@ fn option_option_type_is_optional_value() {
fn option_option_type_help() {
#[derive(Parser, Debug)]
struct Opt {
#[clap(long, value_name = "val")]
#[arg(long, value_name = "val")]
arg: Option<Option<i32>>,
}
let help = utils::get_help::<Opt>();
@ -279,10 +279,10 @@ fn option_option_type_help() {
fn two_option_option_types() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short)]
#[arg(short)]
arg: Option<Option<i32>>,
#[clap(long)]
#[arg(long)]
field: Option<Option<String>>,
}
assert_eq!(
@ -333,7 +333,7 @@ fn two_option_option_types() {
fn vec_type_is_multiple_occurrences() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short, long)]
#[arg(short, long)]
arg: Vec<i32>,
}
assert_eq!(
@ -351,7 +351,7 @@ fn vec_type_is_multiple_occurrences() {
fn vec_type_with_required() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short, long, required = true)]
#[arg(short, long, required = true)]
arg: Vec<i32>,
}
assert_eq!(
@ -369,7 +369,7 @@ fn vec_type_with_required() {
fn vec_type_with_multiple_values_only() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short, long, num_args(1..))]
#[arg(short, long, num_args(1..))]
arg: Vec<i32>,
}
assert_eq!(
@ -391,7 +391,7 @@ fn ignore_qualified_vec_type() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_parser = parser)]
#[arg(value_parser = parser)]
arg: ::std::vec::Vec<String>,
}
@ -407,7 +407,7 @@ fn ignore_qualified_vec_type() {
fn option_vec_type() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short)]
#[arg(short)]
arg: Option<Vec<i32>>,
}
assert_eq!(
@ -429,7 +429,7 @@ fn option_vec_type() {
fn option_vec_type_structopt_behavior() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short, long, num_args(0..))]
#[arg(short, long, num_args(0..))]
arg: Option<Vec<i32>>,
}
assert_eq!(
@ -456,10 +456,10 @@ fn option_vec_type_structopt_behavior() {
fn two_option_vec_types() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(short)]
#[arg(short)]
arg: Option<Vec<i32>>,
#[clap(short)]
#[arg(short)]
b: Option<Vec<i32>>,
}
@ -497,7 +497,7 @@ fn two_option_vec_types() {
fn explicit_value_parser() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(long, value_parser = clap::value_parser!(i32))]
#[arg(long, value_parser = clap::value_parser!(i32))]
arg: i32,
}
assert_eq!(
@ -510,7 +510,7 @@ fn explicit_value_parser() {
fn implicit_value_parser() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(long)]
#[arg(long)]
arg: i32,
}
assert_eq!(

View file

@ -17,7 +17,7 @@ mod options {
#[derive(Debug, Parser)]
pub struct Options {
#[clap(subcommand)]
#[command(subcommand)]
pub subcommand: super::subcommands::SubCommand,
}
}

View file

@ -11,11 +11,11 @@ use clap::Parser;
#[test]
fn raw_bool_literal() {
#[derive(Parser, Debug, PartialEq)]
#[clap(name = "raw_bool")]
#[command(name = "raw_bool")]
struct Opt {
#[clap(raw(false))]
#[arg(raw(false))]
a: String,
#[clap(raw(true))]
#[arg(raw(true))]
b: String,
}

View file

@ -4,7 +4,7 @@ use clap::Parser;
fn raw_idents() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(short, long)]
#[arg(short, long)]
r#type: String,
}

View file

@ -7,9 +7,9 @@ use clap::Parser;
#[test]
fn it_works() {
#[derive(Debug, PartialEq, Parser)]
#[clap(rename_all_env = "kebab")]
#[command(rename_all_env = "kebab")]
struct BehaviorModel {
#[clap(env)]
#[arg(env)]
be_nice: String,
}
@ -21,7 +21,7 @@ fn it_works() {
fn default_is_screaming() {
#[derive(Debug, PartialEq, Parser)]
struct BehaviorModel {
#[clap(env)]
#[arg(env)]
be_nice: String,
}
@ -32,12 +32,12 @@ fn default_is_screaming() {
#[test]
fn overridable() {
#[derive(Debug, PartialEq, Parser)]
#[clap(rename_all_env = "kebab")]
#[command(rename_all_env = "kebab")]
struct BehaviorModel {
#[clap(env)]
#[arg(env)]
be_nice: String,
#[clap(rename_all_env = "pascal", env)]
#[arg(rename_all_env = "pascal", env)]
be_aggressive: String,
}

View file

@ -12,9 +12,9 @@ use clap::Parser;
fn skip_1() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(short)]
#[arg(short)]
x: u32,
#[clap(skip)]
#[arg(skip)]
s: u32,
}
@ -39,15 +39,15 @@ fn skip_1() {
fn skip_2() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(short)]
#[arg(short)]
x: u32,
#[clap(skip)]
#[arg(skip)]
ss: String,
#[clap(skip)]
#[arg(skip)]
sn: u8,
y: u32,
#[clap(skip)]
#[arg(skip)]
sz: u16,
t: u32,
@ -83,11 +83,11 @@ fn skip_enum() {
#[derive(Parser, Debug, PartialEq)]
pub struct Opt {
#[clap(long, short)]
#[arg(long, short)]
number: u32,
#[clap(skip)]
#[arg(skip)]
k: Kind,
#[clap(skip)]
#[arg(skip)]
v: Vec<u32>,
}
@ -105,19 +105,19 @@ fn skip_enum() {
fn skip_help_doc_comments() {
#[derive(Parser, Debug, PartialEq, Eq)]
pub struct Opt {
#[clap(skip, help = "internal_stuff")]
#[arg(skip, help = "internal_stuff")]
a: u32,
#[clap(skip, long_help = "internal_stuff\ndo not touch")]
#[arg(skip, long_help = "internal_stuff\ndo not touch")]
b: u32,
/// Not meant to be used by clap.
///
/// I want a default here.
#[clap(skip)]
#[arg(skip)]
c: u32,
#[clap(short)]
#[arg(short)]
n: u32,
}
@ -136,13 +136,13 @@ fn skip_help_doc_comments() {
fn skip_val() {
#[derive(Parser, Debug, PartialEq, Eq)]
pub struct Opt {
#[clap(long, short)]
#[arg(long, short)]
number: u32,
#[clap(skip = "key")]
#[arg(skip = "key")]
k: String,
#[clap(skip = vec![1, 2, 3])]
#[arg(skip = vec![1, 2, 3])]
v: Vec<u32>,
}

View file

@ -20,19 +20,19 @@ use clap::{Args, Parser, Subcommand};
enum Opt {
/// Fetch stuff from GitHub
Fetch {
#[clap(long)]
#[arg(long)]
all: bool,
/// Overwrite local branches.
#[clap(short, long)]
#[arg(short, long)]
force: bool,
repo: String,
},
Add {
#[clap(short, long)]
#[arg(short, long)]
interactive: bool,
#[clap(short, long)]
#[arg(short, long)]
verbose: bool,
},
}
@ -122,7 +122,7 @@ fn test_null_commands() {
}
#[derive(Parser, PartialEq, Eq, Debug)]
#[clap(about = "Not shown")]
#[command(about = "Not shown")]
struct Add {
file: String,
}
@ -168,9 +168,9 @@ fn test_tuple_commands() {
fn global_passed_down() {
#[derive(Debug, PartialEq, Eq, Parser)]
struct Opt {
#[clap(global = true, long)]
#[arg(global = true, long)]
other: bool,
#[clap(subcommand)]
#[command(subcommand)]
sub: Subcommands,
}
@ -182,7 +182,7 @@ fn global_passed_down() {
#[derive(Debug, PartialEq, Eq, Args)]
struct GlobalCmd {
#[clap(from_global)]
#[arg(from_global)]
other: bool,
}
@ -207,7 +207,7 @@ fn global_passed_down() {
fn external_subcommand() {
#[derive(Debug, PartialEq, Eq, Parser)]
struct Opt {
#[clap(subcommand)]
#[command(subcommand)]
sub: Subcommands,
}
@ -215,7 +215,7 @@ fn external_subcommand() {
enum Subcommands {
Add,
Remove,
#[clap(external_subcommand)]
#[command(external_subcommand)]
Other(Vec<String>),
}
@ -249,13 +249,13 @@ fn external_subcommand_os_string() {
#[derive(Debug, PartialEq, Eq, Parser)]
struct Opt {
#[clap(subcommand)]
#[command(subcommand)]
sub: Subcommands,
}
#[derive(Debug, PartialEq, Eq, Subcommand)]
enum Subcommands {
#[clap(external_subcommand)]
#[command(external_subcommand)]
Other(Vec<OsString>),
}
@ -273,13 +273,13 @@ fn external_subcommand_os_string() {
fn external_subcommand_optional() {
#[derive(Debug, PartialEq, Eq, Parser)]
struct Opt {
#[clap(subcommand)]
#[command(subcommand)]
sub: Option<Subcommands>,
}
#[derive(Debug, PartialEq, Eq, Subcommand)]
enum Subcommands {
#[clap(external_subcommand)]
#[command(external_subcommand)]
Other(Vec<String>),
}
@ -297,9 +297,9 @@ fn external_subcommand_optional() {
fn enum_in_enum_subsubcommand() {
#[derive(Parser, Debug, PartialEq, Eq)]
pub enum Opt {
#[clap(alias = "l")]
#[command(alias = "l")]
List,
#[clap(subcommand, alias = "d")]
#[command(subcommand, alias = "d")]
Daemon(DaemonCommand),
}
@ -378,9 +378,9 @@ fn update_subcommands() {
fn update_sub_subcommands() {
#[derive(Parser, PartialEq, Eq, Debug)]
enum Opt {
#[clap(subcommand)]
#[command(subcommand)]
Child1(Child1),
#[clap(subcommand)]
#[command(subcommand)]
Child2(Child2),
}
@ -451,7 +451,7 @@ fn update_ext_subcommand() {
enum Opt {
Command1(Command1),
Command2(Command2),
#[clap(external_subcommand)]
#[command(external_subcommand)]
Ext(Vec<String>),
}
@ -503,13 +503,13 @@ fn subcommand_name_not_literal() {
#[derive(Parser, PartialEq, Eq, Debug)]
struct Opt {
#[clap(subcommand)]
#[command(subcommand)]
subcmd: SubCmd,
}
#[derive(Subcommand, PartialEq, Eq, Debug)]
enum SubCmd {
#[clap(name = get_name())]
#[command(name = get_name())]
SubCmd1,
}
@ -520,7 +520,7 @@ fn subcommand_name_not_literal() {
fn skip_subcommand() {
#[derive(Debug, PartialEq, Eq, Parser)]
struct Opt {
#[clap(subcommand)]
#[command(subcommand)]
sub: Subcommands,
}
@ -530,7 +530,7 @@ fn skip_subcommand() {
Remove,
#[allow(dead_code)]
#[clap(skip)]
#[command(skip)]
Skip,
}
@ -562,7 +562,7 @@ fn built_in_subcommand_escaped() {
Install {
arg: Option<String>,
},
#[clap(external_subcommand)]
#[command(external_subcommand)]
Custom(Vec<String>),
}

View file

@ -11,9 +11,9 @@ type Option<T> = std::option::Option<T>;
#[derive(Parser)]
pub struct Opts {
another_string: String,
#[clap(subcommand)]
#[command(subcommand)]
command: Command,
#[clap(short, long, value_enum)]
#[arg(short, long, value_enum)]
choice: ArgChoice,
}

View file

@ -12,7 +12,7 @@ struct Positional {
#[derive(Parser, Debug, PartialEq, Eq)]
struct Named {
#[clap(short, long)]
#[arg(short, long)]
arg: String,
}
@ -82,7 +82,7 @@ struct PositionalOs {
#[derive(Parser, Debug, PartialEq, Eq)]
struct NamedOs {
#[clap(short, long)]
#[arg(short, long)]
arg: OsString,
}
@ -171,7 +171,7 @@ fn invalid_utf8_option_long_equals() {
#[derive(Debug, PartialEq, Parser)]
enum External {
#[clap(external_subcommand)]
#[command(external_subcommand)]
Other(Vec<String>),
}
@ -201,7 +201,7 @@ fn refuse_invalid_utf8_subcommand_args_with_allow_external_subcommands() {
#[derive(Debug, PartialEq, Parser)]
enum ExternalOs {
#[clap(external_subcommand)]
#[command(external_subcommand)]
Other(Vec<OsString>),
}

View file

@ -19,7 +19,7 @@ fn basic() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum)]
#[arg(value_enum)]
arg: ArgChoice,
}
@ -54,7 +54,7 @@ fn default_value() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, default_value_t)]
#[arg(value_enum, default_value_t)]
arg: ArgChoice,
}
@ -88,10 +88,10 @@ fn vec_for_default_values_t() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, default_values_t = vec![ArgChoice::Foo, ArgChoice::Bar])]
#[arg(value_enum, default_values_t = vec![ArgChoice::Foo, ArgChoice::Bar])]
arg1: Vec<ArgChoice>,
#[clap(
#[arg(
long,
value_enum,
default_values_t = clap::ValueEnum::value_variants()
@ -139,10 +139,10 @@ fn vec_for_default_values_os_t() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, default_values_os_t = vec![ArgChoice::Foo, ArgChoice::Bar])]
#[arg(value_enum, default_values_os_t = vec![ArgChoice::Foo, ArgChoice::Bar])]
arg: Vec<ArgChoice>,
#[clap(
#[arg(
long,
value_enum,
default_values_os_t = clap::ValueEnum::value_variants()
@ -191,7 +191,7 @@ fn multi_word_is_renamed_kebab() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum)]
#[arg(value_enum)]
arg: ArgChoice,
}
@ -214,13 +214,13 @@ fn multi_word_is_renamed_kebab() {
fn variant_with_defined_casing() {
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
enum ArgChoice {
#[clap(rename_all = "screaming_snake")]
#[value(rename_all = "screaming_snake")]
FooBar,
}
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum)]
#[arg(value_enum)]
arg: ArgChoice,
}
@ -236,14 +236,14 @@ fn variant_with_defined_casing() {
#[test]
fn casing_is_propagated_from_parent() {
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
#[clap(rename_all = "screaming_snake")]
#[value(rename_all = "screaming_snake")]
enum ArgChoice {
FooBar,
}
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum)]
#[arg(value_enum)]
arg: ArgChoice,
}
@ -259,15 +259,15 @@ fn casing_is_propagated_from_parent() {
#[test]
fn casing_propagation_is_overridden() {
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
#[clap(rename_all = "screaming_snake")]
#[value(rename_all = "screaming_snake")]
enum ArgChoice {
#[clap(rename_all = "camel")]
#[value(rename_all = "camel")]
FooBar,
}
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum)]
#[arg(value_enum)]
arg: ArgChoice,
}
@ -290,7 +290,7 @@ fn ignore_case() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, ignore_case(true))]
#[arg(value_enum, ignore_case(true))]
arg: ArgChoice,
}
@ -317,7 +317,7 @@ fn ignore_case_set_to_false() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, ignore_case(false))]
#[arg(value_enum, ignore_case(false))]
arg: ArgChoice,
}
@ -334,13 +334,13 @@ fn ignore_case_set_to_false() {
fn alias() {
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
enum ArgChoice {
#[clap(alias = "TOTP")]
#[value(alias = "TOTP")]
Totp,
}
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, ignore_case(false))]
#[arg(value_enum, ignore_case(false))]
arg: ArgChoice,
}
@ -362,13 +362,13 @@ fn alias() {
fn multiple_alias() {
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
enum ArgChoice {
#[clap(alias = "TOTP", alias = "t")]
#[value(alias = "TOTP", alias = "t")]
Totp,
}
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, ignore_case(false))]
#[arg(value_enum, ignore_case(false))]
arg: ArgChoice,
}
@ -399,7 +399,7 @@ fn skip_variant() {
enum ArgChoice {
Foo,
Bar,
#[clap(skip)]
#[value(skip)]
Baz,
}
@ -430,7 +430,7 @@ fn skip_non_unit_variant() {
enum ArgChoice {
Foo,
Bar,
#[clap(skip)]
#[value(skip)]
Baz(usize),
}
@ -477,7 +477,7 @@ fn option_type() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum)]
#[arg(value_enum)]
arg: Option<ArgChoice>,
}
@ -507,7 +507,7 @@ fn option_option_type() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, long)]
#[arg(value_enum, long)]
arg: Option<Option<ArgChoice>>,
}
@ -541,7 +541,7 @@ fn vec_type() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, short, long)]
#[arg(value_enum, short, long)]
arg: Vec<ArgChoice>,
}
@ -571,7 +571,7 @@ fn option_vec_type() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(value_enum, short, long)]
#[arg(value_enum, short, long)]
arg: Option<Vec<ArgChoice>>,
}
@ -602,7 +602,7 @@ fn vec_type_default_value() {
#[derive(Parser, PartialEq, Debug)]
struct Opt {
#[clap(
#[arg(
value_enum,
short,
long,