mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
docs(derive): Update for new attributes
This commit is contained in:
parent
2609b970a4
commit
0e915e0d3a
64 changed files with 498 additions and 498 deletions
|
@ -19,41 +19,41 @@ use std::io;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[clap(
|
#[command(
|
||||||
name = "value_hints_derive",
|
name = "value_hints_derive",
|
||||||
// Command::trailing_var_ar is required to use ValueHint::CommandWithArguments
|
// Command::trailing_var_ar is required to use ValueHint::CommandWithArguments
|
||||||
trailing_var_arg = true,
|
trailing_var_arg = true,
|
||||||
)]
|
)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
/// If provided, outputs the completion file for given shell
|
/// If provided, outputs the completion file for given shell
|
||||||
#[clap(long = "generate", value_enum)]
|
#[arg(long = "generate", value_enum)]
|
||||||
generator: Option<Shell>,
|
generator: Option<Shell>,
|
||||||
// Showcasing all possible ValueHints:
|
// Showcasing all possible ValueHints:
|
||||||
#[clap(long, value_hint = ValueHint::Unknown)]
|
#[arg(long, value_hint = ValueHint::Unknown)]
|
||||||
unknown: Option<String>,
|
unknown: Option<String>,
|
||||||
#[clap(long, value_hint = ValueHint::Other)]
|
#[arg(long, value_hint = ValueHint::Other)]
|
||||||
other: Option<String>,
|
other: Option<String>,
|
||||||
#[clap(short, long, value_hint = ValueHint::AnyPath)]
|
#[arg(short, long, value_hint = ValueHint::AnyPath)]
|
||||||
path: Option<PathBuf>,
|
path: Option<PathBuf>,
|
||||||
#[clap(short, long, value_hint = ValueHint::FilePath)]
|
#[arg(short, long, value_hint = ValueHint::FilePath)]
|
||||||
file: Option<PathBuf>,
|
file: Option<PathBuf>,
|
||||||
#[clap(short, long, value_hint = ValueHint::DirPath)]
|
#[arg(short, long, value_hint = ValueHint::DirPath)]
|
||||||
dir: Option<PathBuf>,
|
dir: Option<PathBuf>,
|
||||||
#[clap(short, long, value_hint = ValueHint::ExecutablePath)]
|
#[arg(short, long, value_hint = ValueHint::ExecutablePath)]
|
||||||
exe: Option<PathBuf>,
|
exe: Option<PathBuf>,
|
||||||
#[clap(long, value_hint = ValueHint::CommandName)]
|
#[arg(long, value_hint = ValueHint::CommandName)]
|
||||||
cmd_name: Option<OsString>,
|
cmd_name: Option<OsString>,
|
||||||
#[clap(short, long, value_hint = ValueHint::CommandString)]
|
#[arg(short, long, value_hint = ValueHint::CommandString)]
|
||||||
cmd: Option<String>,
|
cmd: Option<String>,
|
||||||
#[clap(value_hint = ValueHint::CommandWithArguments)]
|
#[arg(value_hint = ValueHint::CommandWithArguments)]
|
||||||
command_with_args: Vec<String>,
|
command_with_args: Vec<String>,
|
||||||
#[clap(short, long, value_hint = ValueHint::Username)]
|
#[arg(short, long, value_hint = ValueHint::Username)]
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
#[clap(short, long, value_hint = ValueHint::Hostname)]
|
#[arg(short, long, value_hint = ValueHint::Hostname)]
|
||||||
host: Option<String>,
|
host: Option<String>,
|
||||||
#[clap(long, value_hint = ValueHint::Url)]
|
#[arg(long, value_hint = ValueHint::Url)]
|
||||||
url: Option<String>,
|
url: Option<String>,
|
||||||
#[clap(long, value_hint = ValueHint::EmailAddress)]
|
#[arg(long, value_hint = ValueHint::EmailAddress)]
|
||||||
email: Option<String>,
|
email: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub mod bash {
|
||||||
use unicode_xid::UnicodeXID;
|
use unicode_xid::UnicodeXID;
|
||||||
|
|
||||||
#[derive(clap::Subcommand)]
|
#[derive(clap::Subcommand)]
|
||||||
#[clap(hide = true)]
|
#[command(hide = true)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum CompleteCommand {
|
pub enum CompleteCommand {
|
||||||
|
@ -17,15 +17,15 @@ pub mod bash {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Args)]
|
#[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)]
|
#[allow(missing_docs)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct CompleteArgs {
|
pub struct CompleteArgs {
|
||||||
/// Path to write completion-registration to
|
/// Path to write completion-registration to
|
||||||
#[clap(long, required = true)]
|
#[arg(long, required = true)]
|
||||||
register: Option<std::path::PathBuf>,
|
register: Option<std::path::PathBuf>,
|
||||||
|
|
||||||
#[clap(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
required = true,
|
required = true,
|
||||||
value_name = "COMP_CWORD",
|
value_name = "COMP_CWORD",
|
||||||
|
@ -34,10 +34,10 @@ pub mod bash {
|
||||||
)]
|
)]
|
||||||
index: Option<usize>,
|
index: Option<usize>,
|
||||||
|
|
||||||
#[clap(long, hide_short_help = true, group = "complete")]
|
#[arg(long, hide_short_help = true, group = "complete")]
|
||||||
ifs: Option<String>,
|
ifs: Option<String>,
|
||||||
|
|
||||||
#[clap(
|
#[arg(
|
||||||
long = "type",
|
long = "type",
|
||||||
required = true,
|
required = true,
|
||||||
hide_short_help = true,
|
hide_short_help = true,
|
||||||
|
@ -45,10 +45,10 @@ pub mod bash {
|
||||||
)]
|
)]
|
||||||
comp_type: Option<CompType>,
|
comp_type: Option<CompType>,
|
||||||
|
|
||||||
#[clap(long, hide_short_help = true, group = "complete")]
|
#[arg(long, hide_short_help = true, group = "complete")]
|
||||||
space: bool,
|
space: bool,
|
||||||
|
|
||||||
#[clap(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
conflicts_with = "space",
|
conflicts_with = "space",
|
||||||
hide_short_help = true,
|
hide_short_help = true,
|
||||||
|
@ -56,7 +56,7 @@ pub mod bash {
|
||||||
)]
|
)]
|
||||||
no_space: bool,
|
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>,
|
comp_words: Vec<OsString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)] // requires `derive` feature
|
#[derive(Parser)] // requires `derive` feature
|
||||||
#[clap(name = "cargo")]
|
#[command(name = "cargo")]
|
||||||
#[clap(bin_name = "cargo")]
|
#[command(bin_name = "cargo")]
|
||||||
enum Cargo {
|
enum Cargo {
|
||||||
ExampleDerive(ExampleDerive),
|
ExampleDerive(ExampleDerive),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Args)]
|
#[derive(clap::Args)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct ExampleDerive {
|
struct ExampleDerive {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
manifest_path: Option<std::path::PathBuf>,
|
manifest_path: Option<std::path::PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ use clap::Parser;
|
||||||
|
|
||||||
/// Simple program to greet a person
|
/// Simple program to greet a person
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Name of the person to greet
|
/// Name of the person to greet
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
name: String,
|
name: String,
|
||||||
|
|
||||||
/// Number of times to greet
|
/// Number of times to greet
|
||||||
#[clap(short, long, default_value_t = 1)]
|
#[arg(short, long, default_value_t = 1)]
|
||||||
count: u8,
|
count: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use clap::{arg, Args, Command, FromArgMatches as _};
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
struct DerivedArgs {
|
struct DerivedArgs {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
derived: bool,
|
derived: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use clap::{Command, FromArgMatches as _, Parser, Subcommand as _};
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
enum Subcommands {
|
enum Subcommands {
|
||||||
Derived {
|
Derived {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
derived_flag: bool,
|
derived_flag: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
// Default parser for `Set` is FromStr::from_str.
|
// Default parser for `Set` is FromStr::from_str.
|
||||||
// `impl FromStr for bool` parses `true` or `false` so this
|
// `impl FromStr for bool` parses `true` or `false` so this
|
||||||
// works as expected.
|
// works as expected.
|
||||||
#[clap(long, action = clap::ArgAction::Set)]
|
#[arg(long, action = clap::ArgAction::Set)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
|
|
||||||
// Of course, this could be done with an explicit parser function.
|
// 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,
|
bar: bool,
|
||||||
|
|
||||||
// `bool` can be positional only with explicit `action` annotation
|
// `bool` can be positional only with explicit `action` annotation
|
||||||
#[clap(action = clap::ArgAction::Set)]
|
#[arg(action = clap::ArgAction::Set)]
|
||||||
boom: bool,
|
boom: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,9 @@ impl Args for CliArgs {
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
top_level: bool,
|
top_level: bool,
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
more_args: CliArgs,
|
more_args: CliArgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct AddArgs {
|
||||||
}
|
}
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct RemoveArgs {
|
struct RemoveArgs {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
force: bool,
|
force: bool,
|
||||||
name: Vec<String>,
|
name: Vec<String>,
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ impl Subcommand for CliSub {
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
top_level: bool,
|
top_level: bool,
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
subcommand: CliSub,
|
subcommand: CliSub,
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)] // requires `derive` feature
|
#[derive(Parser)] // requires `derive` feature
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(short = 'f')]
|
#[arg(short = 'f')]
|
||||||
eff: bool,
|
eff: bool,
|
||||||
|
|
||||||
#[clap(short = 'p', value_name = "PEAR")]
|
#[arg(short = 'p', value_name = "PEAR")]
|
||||||
pea: Option<String>,
|
pea: Option<String>,
|
||||||
|
|
||||||
#[clap(last = true)]
|
#[arg(last = true)]
|
||||||
slop: Vec<String>,
|
slop: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,46 +5,46 @@ use clap::{Args, Parser, Subcommand};
|
||||||
|
|
||||||
/// A fictional versioning CLI
|
/// A fictional versioning CLI
|
||||||
#[derive(Debug, Parser)] // requires `derive` feature
|
#[derive(Debug, Parser)] // requires `derive` feature
|
||||||
#[clap(name = "git")]
|
#[command(name = "git")]
|
||||||
#[clap(about = "A fictional versioning CLI", long_about = None)]
|
#[command(about = "A fictional versioning CLI", long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Commands,
|
command: Commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
enum Commands {
|
enum Commands {
|
||||||
/// Clones repos
|
/// Clones repos
|
||||||
#[clap(arg_required_else_help = true)]
|
#[command(arg_required_else_help = true)]
|
||||||
Clone {
|
Clone {
|
||||||
/// The remote to clone
|
/// The remote to clone
|
||||||
remote: String,
|
remote: String,
|
||||||
},
|
},
|
||||||
/// pushes things
|
/// pushes things
|
||||||
#[clap(arg_required_else_help = true)]
|
#[command(arg_required_else_help = true)]
|
||||||
Push {
|
Push {
|
||||||
/// The remote to target
|
/// The remote to target
|
||||||
remote: String,
|
remote: String,
|
||||||
},
|
},
|
||||||
/// adds things
|
/// adds things
|
||||||
#[clap(arg_required_else_help = true)]
|
#[command(arg_required_else_help = true)]
|
||||||
Add {
|
Add {
|
||||||
/// Stuff to add
|
/// Stuff to add
|
||||||
#[clap(required = true)]
|
#[arg(required = true)]
|
||||||
path: Vec<PathBuf>,
|
path: Vec<PathBuf>,
|
||||||
},
|
},
|
||||||
Stash(Stash),
|
Stash(Stash),
|
||||||
#[clap(external_subcommand)]
|
#[command(external_subcommand)]
|
||||||
External(Vec<OsString>),
|
External(Vec<OsString>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
#[clap(args_conflicts_with_subcommands = true)]
|
#[command(args_conflicts_with_subcommands = true)]
|
||||||
struct Stash {
|
struct Stash {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Option<StashCommands>,
|
command: Option<StashCommands>,
|
||||||
|
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
push: StashPush,
|
push: StashPush,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ enum StashCommands {
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
struct StashPush {
|
struct StashPush {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
message: Option<String>,
|
message: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,20 @@ use std::path::PathBuf;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Optional name to operate on
|
/// Optional name to operate on
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
|
|
||||||
/// Sets a custom config file
|
/// Sets a custom config file
|
||||||
#[clap(short, long, value_name = "FILE")]
|
#[arg(short, long, value_name = "FILE")]
|
||||||
config: Option<PathBuf>,
|
config: Option<PathBuf>,
|
||||||
|
|
||||||
/// Turn debugging information on
|
/// Turn debugging information on
|
||||||
#[clap(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
debug: u8,
|
debug: u8,
|
||||||
|
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Option<Commands>,
|
command: Option<Commands>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ enum Commands {
|
||||||
/// does testing things
|
/// does testing things
|
||||||
Test {
|
Test {
|
||||||
/// lists test values
|
/// lists test values
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
list: bool,
|
list: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
#[clap(allow_negative_numbers = true)]
|
#[command(allow_negative_numbers = true)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
two: String,
|
two: String,
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
one: String,
|
one: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "MyApp")]
|
#[command(name = "MyApp")]
|
||||||
#[clap(author = "Kevin K. <kbknapp@gmail.com>")]
|
#[command(author = "Kevin K. <kbknapp@gmail.com>")]
|
||||||
#[clap(version = "1.0")]
|
#[command(version = "1.0")]
|
||||||
#[clap(about = "Does awesome things", long_about = None)]
|
#[command(about = "Does awesome things", long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
two: String,
|
two: String,
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
one: String,
|
one: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(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 {
|
struct Cli {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
two: String,
|
two: String,
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
one: String,
|
one: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
verbose: u8,
|
verbose: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
name: Vec<String>,
|
name: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
name: Vec<String>,
|
name: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ Options:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Because we added `#[clap(propagate_version = true)]`:
|
Because we added `#[command(propagate_version = true)]`:
|
||||||
```console
|
```console
|
||||||
$ 03_04_subcommands_derive --version
|
$ 03_04_subcommands_derive --version
|
||||||
clap [..]
|
clap [..]
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
#[clap(propagate_version = true)]
|
#[command(propagate_version = true)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Commands,
|
command: Commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use clap::{Args, Parser, Subcommand};
|
use clap::{Args, Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
#[clap(propagate_version = true)]
|
#[command(propagate_version = true)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Commands,
|
command: Commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(default_value_t = String::from("alice"))]
|
#[arg(default_value_t = String::from("alice"))]
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use clap::{Parser, ValueEnum};
|
use clap::{Parser, ValueEnum};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// What mode to run the program in
|
/// What mode to run the program in
|
||||||
#[clap(value_enum)]
|
#[arg(value_enum)]
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Network port to use
|
/// Network port to use
|
||||||
#[clap(value_parser = clap::value_parser!(u16).range(1..))]
|
#[arg(value_parser = clap::value_parser!(u16).range(1..))]
|
||||||
port: u16,
|
port: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@ use std::ops::RangeInclusive;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Network port to use
|
/// Network port to use
|
||||||
#[clap(value_parser = port_in_range)]
|
#[arg(value_parser = port_in_range)]
|
||||||
port: u16,
|
port: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
use clap::{ArgGroup, Parser};
|
use clap::{ArgGroup, Parser};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
#[clap(group(
|
#[command(group(
|
||||||
ArgGroup::new("vers")
|
ArgGroup::new("vers")
|
||||||
.required(true)
|
.required(true)
|
||||||
.args(["set_ver", "major", "minor", "patch"]),
|
.args(["set_ver", "major", "minor", "patch"]),
|
||||||
))]
|
))]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// set version manually
|
/// set version manually
|
||||||
#[clap(long, value_name = "VER")]
|
#[arg(long, value_name = "VER")]
|
||||||
set_ver: Option<String>,
|
set_ver: Option<String>,
|
||||||
|
|
||||||
/// auto inc major
|
/// auto inc major
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
major: bool,
|
major: bool,
|
||||||
|
|
||||||
/// auto inc minor
|
/// auto inc minor
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
minor: bool,
|
minor: bool,
|
||||||
|
|
||||||
/// auto inc patch
|
/// auto inc patch
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
patch: bool,
|
patch: bool,
|
||||||
|
|
||||||
/// some regular input
|
/// some regular input
|
||||||
#[clap(group = "input")]
|
#[arg(group = "input")]
|
||||||
input_file: Option<String>,
|
input_file: Option<String>,
|
||||||
|
|
||||||
/// some special input argument
|
/// some special input argument
|
||||||
#[clap(long, group = "input")]
|
#[arg(long, group = "input")]
|
||||||
spec_in: Option<String>,
|
spec_in: Option<String>,
|
||||||
|
|
||||||
#[clap(short, requires = "input")]
|
#[arg(short, requires = "input")]
|
||||||
config: Option<String>,
|
config: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,32 +2,32 @@ use clap::error::ErrorKind;
|
||||||
use clap::{CommandFactory, Parser};
|
use clap::{CommandFactory, Parser};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// set version manually
|
/// set version manually
|
||||||
#[clap(long, value_name = "VER")]
|
#[arg(long, value_name = "VER")]
|
||||||
set_ver: Option<String>,
|
set_ver: Option<String>,
|
||||||
|
|
||||||
/// auto inc major
|
/// auto inc major
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
major: bool,
|
major: bool,
|
||||||
|
|
||||||
/// auto inc minor
|
/// auto inc minor
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
minor: bool,
|
minor: bool,
|
||||||
|
|
||||||
/// auto inc patch
|
/// auto inc patch
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
patch: bool,
|
patch: bool,
|
||||||
|
|
||||||
/// some regular input
|
/// some regular input
|
||||||
input_file: Option<String>,
|
input_file: Option<String>,
|
||||||
|
|
||||||
/// some special input argument
|
/// some special input argument
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
spec_in: Option<String>,
|
spec_in: Option<String>,
|
||||||
|
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
config: Option<String>,
|
config: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Network port to use
|
/// Network port to use
|
||||||
port: u16,
|
port: u16,
|
||||||
|
|
|
@ -4,23 +4,23 @@ use std::error::Error;
|
||||||
#[derive(Parser, Debug)] // requires `derive` feature
|
#[derive(Parser, Debug)] // requires `derive` feature
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Implicitly using `std::str::FromStr`
|
/// Implicitly using `std::str::FromStr`
|
||||||
#[clap(short = 'O')]
|
#[arg(short = 'O')]
|
||||||
optimization: Option<usize>,
|
optimization: Option<usize>,
|
||||||
|
|
||||||
/// Allow invalid UTF-8 paths
|
/// 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>,
|
include: Option<std::path::PathBuf>,
|
||||||
|
|
||||||
/// Handle IP addresses
|
/// Handle IP addresses
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
bind: Option<std::net::IpAddr>,
|
bind: Option<std::net::IpAddr>,
|
||||||
|
|
||||||
/// Allow human-readable durations
|
/// Allow human-readable durations
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
sleep: Option<humantime::Duration>,
|
sleep: Option<humantime::Duration>,
|
||||||
|
|
||||||
/// Hand-written parser for tuples
|
/// 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)>,
|
defines: Vec<(String, i32)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
//!
|
//!
|
||||||
#![doc = include_str!("../../examples/tutorial_derive/02_apps.md")]
|
#![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
|
//! ```rust
|
||||||
#![doc = include_str!("../../examples/tutorial_derive/02_crate.rs")]
|
#![doc = include_str!("../../examples/tutorial_derive/02_crate.rs")]
|
||||||
|
@ -88,9 +88,9 @@
|
||||||
//! - They can be optional
|
//! - They can be optional
|
||||||
//! - Intent is clearer
|
//! - 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
|
//! 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
|
//! ```rust
|
||||||
#![doc = include_str!("../../examples/tutorial_derive/03_02_option.rs")]
|
#![doc = include_str!("../../examples/tutorial_derive/03_02_option.rs")]
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
//! ### Flags
|
//! ### Flags
|
||||||
//!
|
//!
|
||||||
//! Flags can also be switches that can be on/off. This is enabled via the
|
//! 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`.
|
//! `bool`.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
//!
|
//!
|
||||||
//! ### Subcommands
|
//! ### 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
|
//! instance of a [Subcommand][crate::Subcommand] can have its own version, author(s), Args, and even its own
|
||||||
//! subcommands.
|
//! subcommands.
|
||||||
//!
|
//!
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
//!
|
//!
|
||||||
//! We've previously showed that arguments can be [`required`][crate::Arg::required] or optional.
|
//! 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
|
//! 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
|
//! ```rust
|
||||||
#![doc = include_str!("../../examples/tutorial_derive/03_05_default_values.rs")]
|
#![doc = include_str!("../../examples/tutorial_derive/03_05_default_values.rs")]
|
||||||
|
|
|
@ -27,54 +27,54 @@
|
||||||
//!
|
//!
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[derive(Parser)]
|
//! #[derive(Parser)]
|
||||||
//! #[clap(APP ATTRIBUTE)]
|
//! #[command(CMD ATTRIBUTE)]
|
||||||
//! struct Cli {
|
//! struct Cli {
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[clap(ARG ATTRIBUTE)]
|
//! #[arg(ARG ATTRIBUTE)]
|
||||||
//! field: UserType,
|
//! field: UserType,
|
||||||
//!
|
//!
|
||||||
//! #[clap(value_enum, ARG ATTRIBUTE...)]
|
//! #[arg(value_enum, ARG ATTRIBUTE...)]
|
||||||
//! field: EnumValues,
|
//! field: EnumValues,
|
||||||
//!
|
//!
|
||||||
//! #[clap(flatten)]
|
//! #[command(flatten)]
|
||||||
//! delegate: Struct,
|
//! delegate: Struct,
|
||||||
//!
|
//!
|
||||||
//! #[clap(subcommand)]
|
//! #[command(subcommand)]
|
||||||
//! command: Command,
|
//! command: Command,
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[derive(Args)]
|
//! #[derive(Args)]
|
||||||
//! #[clap(PARENT APP ATTRIBUTE)]
|
//! #[command(PARENT CMD ATTRIBUTE)]
|
||||||
//! struct Struct {
|
//! struct Struct {
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[clap(ARG ATTRIBUTE)]
|
//! #[command(ARG ATTRIBUTE)]
|
||||||
//! field: UserType,
|
//! field: UserType,
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[derive(Subcommand)]
|
//! #[derive(Subcommand)]
|
||||||
//! #[clap(PARENT APP ATTRIBUTE)]
|
//! #[command(PARENT CMD ATTRIBUTE)]
|
||||||
//! enum Command {
|
//! enum Command {
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[clap(APP ATTRIBUTE)]
|
//! #[command(CMD ATTRIBUTE)]
|
||||||
//! Variant1(Struct),
|
//! Variant1(Struct),
|
||||||
//!
|
//!
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[clap(APP ATTRIBUTE)]
|
//! #[command(CMD ATTRIBUTE)]
|
||||||
//! Variant2 {
|
//! Variant2 {
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[clap(ARG ATTRIBUTE)]
|
//! #[arg(ARG ATTRIBUTE)]
|
||||||
//! field: UserType,
|
//! field: UserType,
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[derive(ValueEnum)]
|
//! #[derive(ValueEnum)]
|
||||||
//! #[clap(VALUE ENUM ATTRIBUTE)]
|
//! #[value(VALUE ENUM ATTRIBUTE)]
|
||||||
//! enum EnumValues {
|
//! enum EnumValues {
|
||||||
//! /// Doc comment
|
//! /// Doc comment
|
||||||
//! #[clap(POSSIBLE VALUE ATTRIBUTE)]
|
//! #[value(POSSIBLE VALUE ATTRIBUTE)]
|
||||||
//! Variant1,
|
//! Variant1,
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
//!
|
//!
|
||||||
//! Raw attributes come in two different syntaxes:
|
//! Raw attributes come in two different syntaxes:
|
||||||
//! ```rust,ignore
|
//! ```rust,ignore
|
||||||
//! #[clap(
|
//! #[arg(
|
||||||
//! global = true, // name = arg form, neat for one-arg methods
|
//! global = true, // name = arg form, neat for one-arg methods
|
||||||
//! required_if_eq("out", "file") // name(arg1, arg2, ...) form.
|
//! 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,
|
//! **Raw attributes:** Any [`Command` method][crate::Command] can also be used as an attribute,
|
||||||
//! see [Terminology](#terminology) for syntax.
|
//! 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:**
|
//! **Magic attributes:**
|
||||||
//! - `name = <expr>`: [`Command::name`][crate::Command::name]
|
//! - `name = <expr>`: [`Command::name`][crate::Command::name]
|
||||||
|
@ -149,7 +149,7 @@
|
||||||
//! - When not present: [Doc comment summary](#doc-comments)
|
//! - 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)
|
//! - 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
|
//! - **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`.
|
//! gets shown with both `-h` and `--help`.
|
||||||
//! - `long_about = <expr>`: [`Command::long_about`][crate::Command::long_about]
|
//! - `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
|
//! - 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].
|
//! 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.
|
//! **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**:
|
//! **Magic attributes**:
|
||||||
//! - `id = <expr>`: [`Arg::id`][crate::Arg::id]
|
//! - `id = <expr>`: [`Arg::id`][crate::Arg::id]
|
||||||
|
@ -219,16 +219,16 @@
|
||||||
//! - Without `<expr>`: fills the field with `Default::default()`
|
//! - 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 = <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]
|
//! - `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()`
|
//! - Without `<expr>`, relies on `Default::default()`
|
||||||
//! - `default_values_t = <expr>`: [`Arg::default_values`][crate::Arg::default_values] and [`Arg::required(false)`][crate::Arg::required]
|
//! - `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>`
|
//! - `<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]
|
//! - `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()`
|
//! - 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]
|
//! - `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>`
|
//! - `<expr>` must implement `IntoIterator<T>`
|
||||||
//!
|
//!
|
||||||
//! ### ValueEnum Attributes
|
//! ### ValueEnum Attributes
|
||||||
|
@ -242,7 +242,7 @@
|
||||||
//! These correspond to a [`PossibleValue`][crate::builder::PossibleValue].
|
//! 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.
|
//! **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**:
|
//! **Magic attributes**:
|
||||||
//! - `name = <expr>`: [`PossibleValue::new`][crate::builder::PossibleValue::new]
|
//! - `name = <expr>`: [`PossibleValue::new`][crate::builder::PossibleValue::new]
|
||||||
|
@ -282,9 +282,9 @@
|
||||||
//! # use clap::Parser;
|
//! # use clap::Parser;
|
||||||
//!
|
//!
|
||||||
//! #[derive(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 {
|
//! struct Foo {
|
||||||
//! #[clap(short, help = "Pass `-h` and you'll see me!")]
|
//! #[arg(short, help = "Pass `-h` and you'll see me!")]
|
||||||
//! bar: String,
|
//! bar: String,
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
@ -309,7 +309,7 @@
|
||||||
//! If you really want to use the `Command::about/long_about` methods (you likely don't),
|
//! 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
|
//! use the `about` / `long_about` attributes to override the calls generated from
|
||||||
//! the doc comment. To clear `long_about`, you can use
|
//! 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.
|
//! **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
|
//! /// I am artificial superintelligence. I won't rest
|
||||||
//! /// until I'll have destroyed humanity. Enjoy your
|
//! /// until I'll have destroyed humanity. Enjoy your
|
||||||
//! /// pathetic existence, you mere mortals.
|
//! /// pathetic existence, you mere mortals.
|
||||||
//! #[clap(long, action)]
|
//! #[arg(long, action)]
|
||||||
//! kill_all_humans: bool,
|
//! kill_all_humans: bool,
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
@ -380,7 +380,7 @@
|
||||||
//!
|
//!
|
||||||
//! ### Using derived arguments in a builder application
|
//! ### 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
|
//! 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.
|
//! created using the builder API with `Args` created using the derive API.
|
||||||
//!
|
//!
|
||||||
|
@ -398,7 +398,7 @@
|
||||||
//!
|
//!
|
||||||
//! ### Using derived subcommands in a builder application
|
//! ### 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
|
//! 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.
|
//! 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
|
//! ### 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
|
//! 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
|
//! 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
|
//! 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
|
//! [`augment_subcommands`][crate::Subcommand::augment_subcommands] on an enum that derived
|
||||||
//! `Parser`, whereas now we implement
|
//! `Parser`, whereas now we implement
|
||||||
//! [`augment_subcommands`][crate::Subcommand::augment_subcommands] ourselves, but the derive API
|
//! [`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:
|
//! For example:
|
||||||
//! ```rust
|
//! ```rust
|
||||||
|
@ -432,7 +432,7 @@
|
||||||
//!
|
//!
|
||||||
//! ### Flattening hand-implemented args into a derived application
|
//! ### 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
|
//! 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 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
|
//! 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
|
//! Notice how in the previous example we used [`augment_args`][crate::Args::augment_args] on the
|
||||||
//! struct that derived `Parser`, whereas now we implement
|
//! struct that derived `Parser`, whereas now we implement
|
||||||
//! [`augment_args`][crate::Args::augment_args] ourselves, but the derive API calls it
|
//! [`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:
|
//! For example:
|
||||||
//! ```rust
|
//! ```rust
|
||||||
|
|
|
@ -34,13 +34,13 @@ use std::ffi::OsString;
|
||||||
#[cfg_attr(feature = "derive", doc = " ```")]
|
#[cfg_attr(feature = "derive", doc = " ```")]
|
||||||
/// /// My super CLI
|
/// /// My super CLI
|
||||||
/// #[derive(clap::Parser)]
|
/// #[derive(clap::Parser)]
|
||||||
/// #[clap(name = "demo")]
|
/// #[command(name = "demo")]
|
||||||
/// struct Context {
|
/// struct Context {
|
||||||
/// /// More verbose output
|
/// /// More verbose output
|
||||||
/// #[clap(long)]
|
/// #[arg(long)]
|
||||||
/// verbose: bool,
|
/// verbose: bool,
|
||||||
/// /// An optional name
|
/// /// An optional name
|
||||||
/// #[clap(short, long)]
|
/// #[arg(short, long)]
|
||||||
/// name: Option<String>,
|
/// name: Option<String>,
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -257,7 +257,7 @@ pub trait FromArgMatches: Sized {
|
||||||
///
|
///
|
||||||
/// Implementing this trait lets a parent container delegate argument parsing behavior to `Self`.
|
/// Implementing this trait lets a parent container delegate argument parsing behavior to `Self`.
|
||||||
/// with:
|
/// 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`.
|
/// `Args`.
|
||||||
/// - `Variant(ChildArgs)`: No attribute is used with enum variants 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 = " ```")]
|
#[cfg_attr(feature = "derive", doc = " ```")]
|
||||||
/// #[derive(clap::Parser)]
|
/// #[derive(clap::Parser)]
|
||||||
/// struct Args {
|
/// struct Args {
|
||||||
/// #[clap(flatten)]
|
/// #[command(flatten)]
|
||||||
/// logging: LogArgs,
|
/// logging: LogArgs,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// #[derive(clap::Args)]
|
/// #[derive(clap::Args)]
|
||||||
/// struct LogArgs {
|
/// struct LogArgs {
|
||||||
/// #[clap(long, short = 'v', action = clap::ArgAction::Count)]
|
/// #[arg(long, short = 'v', action = clap::ArgAction::Count)]
|
||||||
/// verbose: i8,
|
/// verbose: i8,
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -288,7 +288,7 @@ pub trait Args: FromArgMatches + Sized {
|
||||||
fn augment_args(cmd: Command) -> Command;
|
fn augment_args(cmd: Command) -> Command;
|
||||||
/// Append to [`Command`] so it can update `self`.
|
/// 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`].
|
/// See also [`CommandFactory`].
|
||||||
fn augment_args_for_update(cmd: Command) -> Command;
|
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`.
|
/// Implementing this trait lets a parent container delegate subcommand behavior to `Self`.
|
||||||
/// with:
|
/// 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`.
|
/// 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`.
|
/// `Subcommand`.
|
||||||
///
|
///
|
||||||
/// See the [derive reference](crate::_derive) for attributes and best practices.
|
/// 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 = " ```")]
|
#[cfg_attr(feature = "derive", doc = " ```")]
|
||||||
/// #[derive(clap::Parser)]
|
/// #[derive(clap::Parser)]
|
||||||
/// struct Args {
|
/// struct Args {
|
||||||
/// #[clap(subcommand)]
|
/// #[command(subcommand)]
|
||||||
/// action: Action,
|
/// action: Action,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
@ -330,7 +330,7 @@ pub trait Subcommand: FromArgMatches + Sized {
|
||||||
fn augment_subcommands(cmd: Command) -> Command;
|
fn augment_subcommands(cmd: Command) -> Command;
|
||||||
/// Append to [`Command`] so it can update `self`.
|
/// 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`].
|
/// See also [`CommandFactory`].
|
||||||
fn augment_subcommands_for_update(cmd: Command) -> Command;
|
fn augment_subcommands_for_update(cmd: Command) -> Command;
|
||||||
|
@ -341,9 +341,9 @@ pub trait Subcommand: FromArgMatches + Sized {
|
||||||
/// Parse arguments into enums.
|
/// Parse arguments into enums.
|
||||||
///
|
///
|
||||||
/// When deriving [`Parser`], a field whose type implements `ValueEnum` can have the attribute
|
/// 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]`
|
/// - 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.
|
/// 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 = " ```")]
|
#[cfg_attr(feature = "derive", doc = " ```")]
|
||||||
/// #[derive(clap::Parser)]
|
/// #[derive(clap::Parser)]
|
||||||
/// struct Args {
|
/// struct Args {
|
||||||
/// #[clap(value_enum)]
|
/// #[arg(value_enum)]
|
||||||
/// level: Level,
|
/// level: Level,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
|
|
@ -3,7 +3,7 @@ use clap::Parser;
|
||||||
#[test]
|
#[test]
|
||||||
fn app_name_in_short_help_from_struct() {
|
fn app_name_in_short_help_from_struct() {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "my-cmd")]
|
#[command(name = "my-cmd")]
|
||||||
struct MyApp {}
|
struct MyApp {}
|
||||||
|
|
||||||
let mut help = Vec::new();
|
let mut help = Vec::new();
|
||||||
|
@ -16,7 +16,7 @@ fn app_name_in_short_help_from_struct() {
|
||||||
#[test]
|
#[test]
|
||||||
fn app_name_in_long_help_from_struct() {
|
fn app_name_in_long_help_from_struct() {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "my-cmd")]
|
#[command(name = "my-cmd")]
|
||||||
struct MyApp {}
|
struct MyApp {}
|
||||||
|
|
||||||
let mut help = Vec::new();
|
let mut help = Vec::new();
|
||||||
|
@ -29,7 +29,7 @@ fn app_name_in_long_help_from_struct() {
|
||||||
#[test]
|
#[test]
|
||||||
fn app_name_in_short_help_from_enum() {
|
fn app_name_in_short_help_from_enum() {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "my-cmd")]
|
#[command(name = "my-cmd")]
|
||||||
enum MyApp {}
|
enum MyApp {}
|
||||||
|
|
||||||
let mut help = Vec::new();
|
let mut help = Vec::new();
|
||||||
|
@ -42,7 +42,7 @@ fn app_name_in_short_help_from_enum() {
|
||||||
#[test]
|
#[test]
|
||||||
fn app_name_in_long_help_from_enum() {
|
fn app_name_in_long_help_from_enum() {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "my-cmd")]
|
#[command(name = "my-cmd")]
|
||||||
enum MyApp {}
|
enum MyApp {}
|
||||||
|
|
||||||
let mut help = Vec::new();
|
let mut help = Vec::new();
|
||||||
|
@ -55,7 +55,7 @@ fn app_name_in_long_help_from_enum() {
|
||||||
#[test]
|
#[test]
|
||||||
fn app_name_in_short_version_from_struct() {
|
fn app_name_in_short_version_from_struct() {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "my-cmd")]
|
#[command(name = "my-cmd")]
|
||||||
struct MyApp {}
|
struct MyApp {}
|
||||||
|
|
||||||
let version = MyApp::command().render_version();
|
let version = MyApp::command().render_version();
|
||||||
|
@ -66,7 +66,7 @@ fn app_name_in_short_version_from_struct() {
|
||||||
#[test]
|
#[test]
|
||||||
fn app_name_in_long_version_from_struct() {
|
fn app_name_in_long_version_from_struct() {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "my-cmd")]
|
#[command(name = "my-cmd")]
|
||||||
struct MyApp {}
|
struct MyApp {}
|
||||||
|
|
||||||
let version = MyApp::command().render_long_version();
|
let version = MyApp::command().render_long_version();
|
||||||
|
@ -77,7 +77,7 @@ fn app_name_in_long_version_from_struct() {
|
||||||
#[test]
|
#[test]
|
||||||
fn app_name_in_short_version_from_enum() {
|
fn app_name_in_short_version_from_enum() {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "my-cmd")]
|
#[command(name = "my-cmd")]
|
||||||
enum MyApp {}
|
enum MyApp {}
|
||||||
|
|
||||||
let version = MyApp::command().render_version();
|
let version = MyApp::command().render_version();
|
||||||
|
@ -88,7 +88,7 @@ fn app_name_in_short_version_from_enum() {
|
||||||
#[test]
|
#[test]
|
||||||
fn app_name_in_long_version_from_enum() {
|
fn app_name_in_long_version_from_enum() {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(name = "my-cmd")]
|
#[command(name = "my-cmd")]
|
||||||
enum MyApp {}
|
enum MyApp {}
|
||||||
|
|
||||||
let version = MyApp::command().render_long_version();
|
let version = MyApp::command().render_long_version();
|
||||||
|
|
|
@ -33,7 +33,7 @@ fn required_argument() {
|
||||||
fn argument_with_default() {
|
fn argument_with_default() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(default_value = "42")]
|
#[arg(default_value = "42")]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -67,7 +67,7 @@ fn auto_value_name() {
|
||||||
fn explicit_value_name() {
|
fn explicit_value_name() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_name = "BROWNIE_POINTS")]
|
#[arg(value_name = "BROWNIE_POINTS")]
|
||||||
my_special_arg: i32,
|
my_special_arg: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ use clap::Parser;
|
||||||
#[test]
|
#[test]
|
||||||
fn no_author_version_about() {
|
fn no_author_version_about() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
#[clap(name = "foo")]
|
#[command(name = "foo")]
|
||||||
#[clap(help_template = utils::FULL_TEMPLATE)]
|
#[command(help_template = utils::FULL_TEMPLATE)]
|
||||||
struct Opt {}
|
struct Opt {}
|
||||||
|
|
||||||
let output = utils::get_long_help::<Opt>();
|
let output = utils::get_long_help::<Opt>();
|
||||||
|
@ -30,8 +30,8 @@ fn no_author_version_about() {
|
||||||
#[test]
|
#[test]
|
||||||
fn use_env() {
|
fn use_env() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
#[clap(author, about, version)]
|
#[command(author, about, version)]
|
||||||
#[clap(help_template = utils::FULL_TEMPLATE)]
|
#[command(help_template = utils::FULL_TEMPLATE)]
|
||||||
struct Opt {}
|
struct Opt {}
|
||||||
|
|
||||||
let output = utils::get_long_help::<Opt>();
|
let output = utils::get_long_help::<Opt>();
|
||||||
|
@ -45,8 +45,8 @@ fn explicit_version_not_str_lit() {
|
||||||
const VERSION: &str = "custom version";
|
const VERSION: &str = "custom version";
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(version = VERSION)]
|
#[command(version = VERSION)]
|
||||||
#[clap(help_template = utils::FULL_TEMPLATE)]
|
#[command(help_template = utils::FULL_TEMPLATE)]
|
||||||
pub struct Opt {}
|
pub struct Opt {}
|
||||||
|
|
||||||
let output = utils::get_long_help::<Opt>();
|
let output = utils::get_long_help::<Opt>();
|
||||||
|
|
|
@ -18,7 +18,7 @@ use clap::Parser;
|
||||||
fn basic() {
|
fn basic() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short = 'a', long = "arg")]
|
#[arg(short = 'a', long = "arg")]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -31,7 +31,7 @@ fn basic() {
|
||||||
fn update_basic() {
|
fn update_basic() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short = 'a', long = "arg")]
|
#[arg(short = 'a', long = "arg")]
|
||||||
single_value: i32,
|
single_value: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ use clap::{Args, Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
sub: Box<Sub>,
|
sub: Box<Sub>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand, PartialEq, Debug)]
|
#[derive(Subcommand, PartialEq, Debug)]
|
||||||
enum Sub {
|
enum Sub {
|
||||||
Flame {
|
Flame {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
arg: Box<Ext>,
|
arg: Box<Ext>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,19 +19,19 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct PathOpt {
|
struct PathOpt {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
|
|
||||||
#[clap(short, default_value = "../")]
|
#[arg(short, default_value = "../")]
|
||||||
default_path: PathBuf,
|
default_path: PathBuf,
|
||||||
|
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
vector_path: Vec<PathBuf>,
|
vector_path: Vec<PathBuf>,
|
||||||
|
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
option_path_1: Option<PathBuf>,
|
option_path_1: Option<PathBuf>,
|
||||||
|
|
||||||
#[clap(short = 'q')]
|
#[arg(short = 'q')]
|
||||||
option_path_2: Option<PathBuf>,
|
option_path_2: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ fn parse_hex(input: &str) -> Result<u64, ParseIntError> {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct HexOpt {
|
struct HexOpt {
|
||||||
#[clap(short, value_parser = parse_hex)]
|
#[arg(short, value_parser = parse_hex)]
|
||||||
number: u64,
|
number: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ fn custom_parser_2(_: &str) -> Result<&'static str, ErrCode> {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct NoOpOpt {
|
struct NoOpOpt {
|
||||||
#[clap(short, value_parser = custom_parser_2)]
|
#[arg(short, value_parser = custom_parser_2)]
|
||||||
b: &'static str,
|
b: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,10 +125,10 @@ fn update_every_custom_parser() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct DefaultedOpt {
|
struct DefaultedOpt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
integer: u64,
|
integer: u64,
|
||||||
|
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::utils;
|
||||||
fn default_value() {
|
fn default_value() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(default_value = "3")]
|
#[arg(default_value = "3")]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap());
|
assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap());
|
||||||
|
@ -22,7 +22,7 @@ fn default_value() {
|
||||||
fn default_value_t() {
|
fn default_value_t() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(default_value_t = 3)]
|
#[arg(default_value_t = 3)]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap());
|
assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap());
|
||||||
|
@ -36,7 +36,7 @@ fn default_value_t() {
|
||||||
fn auto_default_value_t() {
|
fn auto_default_value_t() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(default_value_t)]
|
#[arg(default_value_t)]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(Opt { arg: 0 }, Opt::try_parse_from(&["test"]).unwrap());
|
assert_eq!(Opt { arg: 0 }, Opt::try_parse_from(&["test"]).unwrap());
|
||||||
|
@ -50,22 +50,22 @@ fn auto_default_value_t() {
|
||||||
fn default_values_t() {
|
fn default_values_t() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(default_values_t = vec![1, 2, 3])]
|
#[arg(default_values_t = vec![1, 2, 3])]
|
||||||
arg1: Vec<i32>,
|
arg1: Vec<i32>,
|
||||||
|
|
||||||
#[clap(long, default_values_t = &[4, 5, 6])]
|
#[arg(long, default_values_t = &[4, 5, 6])]
|
||||||
arg2: Vec<i32>,
|
arg2: Vec<i32>,
|
||||||
|
|
||||||
#[clap(long, default_values_t = [7, 8, 9])]
|
#[arg(long, default_values_t = [7, 8, 9])]
|
||||||
arg3: Vec<i32>,
|
arg3: Vec<i32>,
|
||||||
|
|
||||||
#[clap(long, default_values_t = 10..=12)]
|
#[arg(long, default_values_t = 10..=12)]
|
||||||
arg4: Vec<i32>,
|
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>,
|
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>,
|
arg6: Vec<String>,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -110,7 +110,7 @@ fn default_values_t() {
|
||||||
fn default_value_os_t() {
|
fn default_value_os_t() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(default_value_os_t = PathBuf::from("abc.def"))]
|
#[arg(default_value_os_t = PathBuf::from("abc.def"))]
|
||||||
arg: PathBuf,
|
arg: PathBuf,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -134,12 +134,12 @@ fn default_value_os_t() {
|
||||||
fn default_values_os_t() {
|
fn default_values_os_t() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(
|
#[arg(
|
||||||
default_values_os_t = vec![PathBuf::from("abc.def"), PathBuf::from("123.foo")]
|
default_values_os_t = vec![PathBuf::from("abc.def"), PathBuf::from("123.foo")]
|
||||||
)]
|
)]
|
||||||
arg1: Vec<PathBuf>,
|
arg1: Vec<PathBuf>,
|
||||||
|
|
||||||
#[clap(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
default_values_os_t = &[PathBuf::from("bar.baz")]
|
default_values_os_t = &[PathBuf::from("bar.baz")]
|
||||||
)]
|
)]
|
||||||
|
@ -170,7 +170,7 @@ fn detect_os_variant() {
|
||||||
|
|
||||||
#[derive(clap::Parser)]
|
#[derive(clap::Parser)]
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
#[clap(default_value_os = "123")]
|
#[arg(default_value_os = "123")]
|
||||||
x: String,
|
x: String,
|
||||||
}
|
}
|
||||||
Options::command().debug_assert();
|
Options::command().debug_assert();
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn try_str(s: &str) -> Result<String, std::convert::Infallible> {
|
||||||
fn warning_never_struct() {
|
fn warning_never_struct() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_parser = try_str, default_value_t)]
|
#[arg(value_parser = try_str, default_value_t)]
|
||||||
s: String,
|
s: String,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -40,7 +40,7 @@ fn warning_never_enum() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
enum Opt {
|
enum Opt {
|
||||||
Foo {
|
Foo {
|
||||||
#[clap(value_parser = try_str, default_value_t)]
|
#[arg(value_parser = try_str, default_value_t)]
|
||||||
s: String,
|
s: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ fn doc_comments() {
|
||||||
struct LoremIpsum {
|
struct LoremIpsum {
|
||||||
/// Fooify a bar
|
/// Fooify a bar
|
||||||
/// and a baz
|
/// and a baz
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@ fn doc_comments() {
|
||||||
fn help_is_better_than_comments() {
|
fn help_is_better_than_comments() {
|
||||||
/// Lorem ipsum
|
/// Lorem ipsum
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
#[clap(name = "lorem-ipsum", about = "Dolor sit amet")]
|
#[command(name = "lorem-ipsum", about = "Dolor sit amet")]
|
||||||
struct LoremIpsum {
|
struct LoremIpsum {
|
||||||
/// Fooify a bar
|
/// 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,
|
foo: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ fn empty_line_in_doc_comment_is_double_linefeed() {
|
||||||
///
|
///
|
||||||
/// Bar
|
/// Bar
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
#[clap(name = "lorem-ipsum")]
|
#[command(name = "lorem-ipsum")]
|
||||||
struct LoremIpsum {}
|
struct LoremIpsum {}
|
||||||
|
|
||||||
let help = utils::get_long_help::<LoremIpsum>();
|
let help = utils::get_long_help::<LoremIpsum>();
|
||||||
|
@ -73,16 +73,16 @@ Usage:"
|
||||||
fn field_long_doc_comment_both_help_long_help() {
|
fn field_long_doc_comment_both_help_long_help() {
|
||||||
/// Lorem ipsumclap
|
/// Lorem ipsumclap
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
#[clap(name = "lorem-ipsum", about = "Dolor sit amet")]
|
#[command(name = "lorem-ipsum", about = "Dolor sit amet")]
|
||||||
struct LoremIpsum {
|
struct LoremIpsum {
|
||||||
/// Dot is removed from multiline comments.
|
/// Dot is removed from multiline comments.
|
||||||
///
|
///
|
||||||
/// Long help
|
/// Long help
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
|
|
||||||
/// Dot is removed from one short comment.
|
/// Dot is removed from one short comment.
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
bar: bool,
|
bar: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,9 +101,9 @@ fn field_long_doc_comment_both_help_long_help() {
|
||||||
fn top_long_doc_comment_both_help_long_help() {
|
fn top_long_doc_comment_both_help_long_help() {
|
||||||
/// Lorem ipsumclap
|
/// Lorem ipsumclap
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(name = "lorem-ipsum", about = "Dolor sit amet")]
|
#[command(name = "lorem-ipsum", about = "Dolor sit amet")]
|
||||||
struct LoremIpsum {
|
struct LoremIpsum {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
foo: SubCommand,
|
foo: SubCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ fn top_long_doc_comment_both_help_long_help() {
|
||||||
///
|
///
|
||||||
/// Or something else
|
/// Or something else
|
||||||
Foo {
|
Foo {
|
||||||
#[clap(help = "foo")]
|
#[arg(help = "foo")]
|
||||||
bars: String,
|
bars: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -146,9 +146,9 @@ fn verbatim_doc_comment() {
|
||||||
/// ( () ||
|
/// ( () ||
|
||||||
/// ( () ) )
|
/// ( () ) )
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(verbatim_doc_comment)]
|
#[command(verbatim_doc_comment)]
|
||||||
struct SeeFigure1 {
|
struct SeeFigure1 {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,10 +178,10 @@ fn verbatim_doc_comment_field() {
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Command {
|
struct Command {
|
||||||
/// This help ends in a period.
|
/// This help ends in a period.
|
||||||
#[clap(long, verbatim_doc_comment)]
|
#[arg(long, verbatim_doc_comment)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
/// This help does not end in a period.
|
/// This help does not end in a period.
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
bar: bool,
|
bar: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ fn multiline_separates_default() {
|
||||||
/// Multiline
|
/// Multiline
|
||||||
///
|
///
|
||||||
/// Doc comment
|
/// Doc comment
|
||||||
#[clap(long, default_value = "x")]
|
#[arg(long, default_value = "x")]
|
||||||
x: String,
|
x: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ fn doc_comment_about_handles_both_abouts() {
|
||||||
/// Opts doc comment summary
|
/// Opts doc comment summary
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
pub struct Opts {
|
pub struct Opts {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
pub cmd: Sub,
|
pub cmd: Sub,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use clap::Parser;
|
||||||
fn explicit_short_long_no_rename() {
|
fn explicit_short_long_no_rename() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short = '.', long = ".foo")]
|
#[arg(short = '.', long = ".foo")]
|
||||||
foo: String,
|
foo: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ fn explicit_short_long_no_rename() {
|
||||||
fn explicit_name_no_rename() {
|
fn explicit_name_no_rename() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(name = ".options")]
|
#[arg(name = ".options")]
|
||||||
foo: String,
|
foo: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ use clap::Parser;
|
||||||
fn bool_type_is_flag() {
|
fn bool_type_is_flag() {
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
alice: bool,
|
alice: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +58,9 @@ fn non_bool_type_flag() {
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Opt {
|
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,
|
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,
|
bob: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ fn inferred_help() {
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
/// Foo
|
/// Foo
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
help: bool,
|
help: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ fn inferred_version() {
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
/// Foo
|
/// Foo
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
version: bool,
|
version: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +130,9 @@ fn inferred_version() {
|
||||||
fn count() {
|
fn count() {
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
alice: u8,
|
alice: u8,
|
||||||
#[clap(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
bob: u8,
|
bob: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,9 +164,9 @@ fn count() {
|
||||||
fn mixed_type_flags() {
|
fn mixed_type_flags() {
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
alice: bool,
|
alice: bool,
|
||||||
#[clap(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
bob: u8,
|
bob: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ fn ignore_qualified_bool_type() {
|
||||||
fn override_implicit_action() {
|
fn override_implicit_action() {
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long, action = clap::ArgAction::Set)]
|
#[arg(long, action = clap::ArgAction::Set)]
|
||||||
arg: bool,
|
arg: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ fn override_implicit_action() {
|
||||||
fn override_implicit_from_flag_positional() {
|
fn override_implicit_from_flag_positional() {
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(action = clap::ArgAction::Set)]
|
#[arg(action = clap::ArgAction::Set)]
|
||||||
arg: bool,
|
arg: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn flatten() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
common: Common,
|
common: Common,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -49,10 +49,10 @@ fn flatten_twice() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
c1: Common,
|
c1: Common,
|
||||||
// Defines "arg" twice, so this should not work.
|
// Defines "arg" twice, so this should not work.
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
c2: Common,
|
c2: Common,
|
||||||
}
|
}
|
||||||
Opt::try_parse_from(&["test", "42", "43"]).unwrap();
|
Opt::try_parse_from(&["test", "42", "43"]).unwrap();
|
||||||
|
@ -67,18 +67,18 @@ fn flatten_in_subcommand() {
|
||||||
|
|
||||||
#[derive(Args, PartialEq, Debug)]
|
#[derive(Args, PartialEq, Debug)]
|
||||||
struct Add {
|
struct Add {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
interactive: bool,
|
interactive: bool,
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
common: Common,
|
common: Common,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
enum Opt {
|
enum Opt {
|
||||||
Fetch {
|
Fetch {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
all: bool,
|
all: bool,
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
common: Common,
|
common: Common,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ fn update_args_with_flatten() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
common: Common,
|
common: Common,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ struct Command2 {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
enum Opt {
|
enum Opt {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
BaseCli(BaseCli),
|
BaseCli(BaseCli),
|
||||||
Command2(Command2),
|
Command2(Command2),
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ fn flatten_with_doc_comment() {
|
||||||
struct Opt {
|
struct Opt {
|
||||||
/// The very important comment that clippy had me put here.
|
/// The very important comment that clippy had me put here.
|
||||||
/// It knows better.
|
/// It knows better.
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
common: Common,
|
common: Common,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -216,18 +216,18 @@ fn flatten_with_doc_comment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn docstrings_ordering_with_multiple_clap() {
|
fn docstrings_ordering_with_multiple_command() {
|
||||||
/// This is the docstring for Flattened
|
/// This is the docstring for Flattened
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
struct Flattened {
|
struct Flattened {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is the docstring for Command
|
/// This is the docstring for Command
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
struct Command {
|
struct Command {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
flattened: Flattened,
|
flattened: Flattened,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,13 +241,13 @@ fn docstrings_ordering_with_multiple_clap_partial() {
|
||||||
/// This is the docstring for Flattened
|
/// This is the docstring for Flattened
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
struct Flattened {
|
struct Flattened {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
struct Command {
|
struct Command {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
flattened: Flattened,
|
flattened: Flattened,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ fn generic_struct_flatten() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Outer<T: Args> {
|
struct Outer<T: Args> {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
pub inner: T,
|
pub inner: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ fn generic_struct_flatten_w_where_clause() {
|
||||||
where
|
where
|
||||||
T: Args,
|
T: Args,
|
||||||
{
|
{
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
pub inner: T,
|
pub inner: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ fn generic_wo_trait_bound() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt<T> {
|
struct Opt<T> {
|
||||||
answer: isize,
|
answer: isize,
|
||||||
#[clap(skip)]
|
#[arg(skip)]
|
||||||
took: Option<T>,
|
took: Option<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ use clap::{ArgAction, Args, CommandFactory, Parser, Subcommand};
|
||||||
fn arg_help_heading_applied() {
|
fn arg_help_heading_applied() {
|
||||||
#[derive(Debug, Clone, Parser)]
|
#[derive(Debug, Clone, Parser)]
|
||||||
struct CliOptions {
|
struct CliOptions {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
#[clap(help_heading = Some("HEADING A"))]
|
#[arg(help_heading = Some("HEADING A"))]
|
||||||
should_be_in_section_a: u32,
|
should_be_in_section_a: u32,
|
||||||
|
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
no_section: u32,
|
no_section: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ fn arg_help_heading_applied() {
|
||||||
#[test]
|
#[test]
|
||||||
fn app_help_heading_applied() {
|
fn app_help_heading_applied() {
|
||||||
#[derive(Debug, Clone, Parser)]
|
#[derive(Debug, Clone, Parser)]
|
||||||
#[clap(next_help_heading = "DEFAULT")]
|
#[command(next_help_heading = "DEFAULT")]
|
||||||
struct CliOptions {
|
struct CliOptions {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
#[clap(help_heading = Some("HEADING A"))]
|
#[arg(help_heading = Some("HEADING A"))]
|
||||||
should_be_in_section_a: u32,
|
should_be_in_section_a: u32,
|
||||||
|
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
should_be_in_default_section: u32,
|
should_be_in_default_section: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,41 +65,41 @@ fn app_help_heading_flattened() {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Parser)]
|
#[derive(Debug, Clone, Parser)]
|
||||||
struct CliOptions {
|
struct CliOptions {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
options_a: OptionsA,
|
options_a: OptionsA,
|
||||||
|
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
options_b: OptionsB,
|
options_b: OptionsB,
|
||||||
|
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
sub_a: SubA,
|
sub_a: SubA,
|
||||||
|
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
should_be_in_default_section: u32,
|
should_be_in_default_section: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Args)]
|
#[derive(Debug, Clone, Args)]
|
||||||
#[clap(next_help_heading = "HEADING A")]
|
#[command(next_help_heading = "HEADING A")]
|
||||||
struct OptionsA {
|
struct OptionsA {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
should_be_in_section_a: u32,
|
should_be_in_section_a: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Args)]
|
#[derive(Debug, Clone, Args)]
|
||||||
#[clap(next_help_heading = "HEADING B")]
|
#[command(next_help_heading = "HEADING B")]
|
||||||
struct OptionsB {
|
struct OptionsB {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
should_be_in_section_b: u32,
|
should_be_in_section_b: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Subcommand)]
|
#[derive(Debug, Clone, Subcommand)]
|
||||||
enum SubA {
|
enum SubA {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
SubB(SubB),
|
SubB(SubB),
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
SubC(SubC),
|
SubC(SubC),
|
||||||
SubAOne,
|
SubAOne,
|
||||||
#[clap(next_help_heading = "SUB A")]
|
#[command(next_help_heading = "SUB A")]
|
||||||
SubATwo {
|
SubATwo {
|
||||||
should_be_in_sub_a: u32,
|
should_be_in_sub_a: u32,
|
||||||
},
|
},
|
||||||
|
@ -107,13 +107,13 @@ fn app_help_heading_flattened() {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Subcommand)]
|
#[derive(Debug, Clone, Subcommand)]
|
||||||
enum SubB {
|
enum SubB {
|
||||||
#[clap(next_help_heading = "SUB B")]
|
#[command(next_help_heading = "SUB B")]
|
||||||
SubBOne { should_be_in_sub_b: u32 },
|
SubBOne { should_be_in_sub_b: u32 },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Subcommand)]
|
#[derive(Debug, Clone, Subcommand)]
|
||||||
enum SubC {
|
enum SubC {
|
||||||
#[clap(next_help_heading = "SUB C")]
|
#[command(next_help_heading = "SUB C")]
|
||||||
SubCOne { should_be_in_sub_c: u32 },
|
SubCOne { should_be_in_sub_c: u32 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,14 +167,14 @@ fn app_help_heading_flattened() {
|
||||||
fn flatten_field_with_help_heading() {
|
fn flatten_field_with_help_heading() {
|
||||||
#[derive(Debug, Clone, Parser)]
|
#[derive(Debug, Clone, Parser)]
|
||||||
struct CliOptions {
|
struct CliOptions {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
#[clap(next_help_heading = "HEADING A")]
|
#[command(next_help_heading = "HEADING A")]
|
||||||
options_a: OptionsA,
|
options_a: OptionsA,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Args)]
|
#[derive(Debug, Clone, Args)]
|
||||||
struct OptionsA {
|
struct OptionsA {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
should_be_in_section_a: u32,
|
should_be_in_section_a: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,19 +194,19 @@ fn flatten_field_with_help_heading() {
|
||||||
#[test]
|
#[test]
|
||||||
fn derive_generated_error_has_full_context() {
|
fn derive_generated_error_has_full_context() {
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[clap(subcommand_negates_reqs = true)]
|
#[command(subcommand_negates_reqs = true)]
|
||||||
struct Opts {
|
struct Opts {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
req_str: String,
|
req_str: String,
|
||||||
|
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Option<SubCommands>,
|
cmd: Option<SubCommands>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
enum SubCommands {
|
enum SubCommands {
|
||||||
Sub {
|
Sub {
|
||||||
#[clap(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
verbose: u8,
|
verbose: u8,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -245,33 +245,33 @@ Options:
|
||||||
";
|
";
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(name = "test", version = "1.2")]
|
#[command(name = "test", version = "1.2")]
|
||||||
struct Args {
|
struct Args {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
a: A,
|
a: A,
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
b: B,
|
b: B,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
#[clap(next_display_order = 10000)]
|
#[command(next_display_order = 10000)]
|
||||||
struct A {
|
struct A {
|
||||||
/// second flag
|
/// second flag
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
flag_a: bool,
|
flag_a: bool,
|
||||||
/// second option
|
/// second option
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
option_a: Option<String>,
|
option_a: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
#[clap(next_display_order = 10)]
|
#[command(next_display_order = 10)]
|
||||||
struct B {
|
struct B {
|
||||||
/// first flag
|
/// first flag
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
flag_b: bool,
|
flag_b: bool,
|
||||||
/// first option
|
/// first option
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
option_b: Option<String>,
|
option_b: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,33 +300,33 @@ Options:
|
||||||
";
|
";
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(name = "test", version = "1.2")]
|
#[command(name = "test", version = "1.2")]
|
||||||
struct Args {
|
struct Args {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
#[clap(next_display_order = 10000)]
|
#[command(next_display_order = 10000)]
|
||||||
a: A,
|
a: A,
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
#[clap(next_display_order = 10)]
|
#[command(next_display_order = 10)]
|
||||||
b: B,
|
b: B,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
struct A {
|
struct A {
|
||||||
/// second flag
|
/// second flag
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
flag_a: bool,
|
flag_a: bool,
|
||||||
/// second option
|
/// second option
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
option_a: Option<String>,
|
option_a: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
struct B {
|
struct B {
|
||||||
/// first flag
|
/// first flag
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
flag_b: bool,
|
flag_b: bool,
|
||||||
/// first option
|
/// first option
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
option_b: Option<String>,
|
option_b: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,32 +355,32 @@ Options:
|
||||||
";
|
";
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(name = "test", version = "1.2")]
|
#[command(name = "test", version = "1.2")]
|
||||||
#[clap(next_display_order = None)]
|
#[command(next_display_order = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
a: A,
|
a: A,
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
b: B,
|
b: B,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
struct A {
|
struct A {
|
||||||
/// first flag
|
/// first flag
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
flag_a: bool,
|
flag_a: bool,
|
||||||
/// first option
|
/// first option
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
option_a: Option<String>,
|
option_a: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
struct B {
|
struct B {
|
||||||
/// second flag
|
/// second flag
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
flag_b: bool,
|
flag_b: bool,
|
||||||
/// second option
|
/// second option
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
option_b: Option<String>,
|
option_b: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ Options:
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Argument help
|
/// Argument help
|
||||||
#[clap(value_enum)]
|
#[arg(value_enum)]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,9 +442,9 @@ Options:
|
||||||
#[test]
|
#[test]
|
||||||
fn custom_help_flag() {
|
fn custom_help_flag() {
|
||||||
#[derive(Debug, Clone, Parser)]
|
#[derive(Debug, Clone, Parser)]
|
||||||
#[clap(disable_help_flag = true)]
|
#[command(disable_help_flag = true)]
|
||||||
struct CliOptions {
|
struct CliOptions {
|
||||||
#[clap(short = 'h', long = "verbose-help", action = ArgAction::Help)]
|
#[arg(short = 'h', long = "verbose-help", action = ArgAction::Help)]
|
||||||
help: bool,
|
help: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,9 +456,9 @@ fn custom_help_flag() {
|
||||||
#[test]
|
#[test]
|
||||||
fn custom_version_flag() {
|
fn custom_version_flag() {
|
||||||
#[derive(Debug, Clone, Parser)]
|
#[derive(Debug, Clone, Parser)]
|
||||||
#[clap(disable_version_flag = true, version = "2.0.0")]
|
#[command(disable_version_flag = true, version = "2.0.0")]
|
||||||
struct CliOptions {
|
struct CliOptions {
|
||||||
#[clap(short = 'V', long = "verbose-version", action = ArgAction::Version)]
|
#[arg(short = 'V', long = "verbose-version", action = ArgAction::Version)]
|
||||||
version: bool,
|
version: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,17 @@ use clap::{ArgGroup, Args, Parser, Subcommand};
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_151_groups_within_subcommands() {
|
fn issue_151_groups_within_subcommands() {
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
#[clap(group = ArgGroup::new("verb").required(true).multiple(true))]
|
#[command(group = ArgGroup::new("verb").required(true).multiple(true))]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long, group = "verb")]
|
#[arg(long, group = "verb")]
|
||||||
foo: Option<String>,
|
foo: Option<String>,
|
||||||
#[clap(long, group = "verb")]
|
#[arg(long, group = "verb")]
|
||||||
bar: Option<String>,
|
bar: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
a: Opt,
|
a: Opt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,17 +31,17 @@ fn issue_151_groups_within_subcommands() {
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_289() {
|
fn issue_289() {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(infer_subcommands = true)]
|
#[command(infer_subcommands = true)]
|
||||||
enum Args {
|
enum Args {
|
||||||
SomeCommand {
|
SomeCommand {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
sub: SubSubCommand,
|
sub: SubSubCommand,
|
||||||
},
|
},
|
||||||
AnotherCommand,
|
AnotherCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
#[clap(infer_subcommands = true)]
|
#[command(infer_subcommands = true)]
|
||||||
enum SubSubCommand {
|
enum SubSubCommand {
|
||||||
TestCommand,
|
TestCommand,
|
||||||
}
|
}
|
||||||
|
@ -59,10 +59,10 @@ fn issue_324() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(version = my_version())]
|
#[command(version = my_version())]
|
||||||
#[clap(help_template = utils::FULL_TEMPLATE)]
|
#[command(help_template = utils::FULL_TEMPLATE)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
_cmd: SubCommand,
|
_cmd: SubCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ fn issue_324() {
|
||||||
fn issue_418() {
|
fn issue_418() {
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
struct Opts {
|
struct Opts {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
/// The command to run
|
/// The command to run
|
||||||
command: Command,
|
command: Command,
|
||||||
}
|
}
|
||||||
|
@ -87,13 +87,13 @@ fn issue_418() {
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
enum Command {
|
enum Command {
|
||||||
/// Reticulate the splines
|
/// Reticulate the splines
|
||||||
#[clap(visible_alias = "ret")]
|
#[command(visible_alias = "ret")]
|
||||||
Reticulate {
|
Reticulate {
|
||||||
/// How many splines
|
/// How many splines
|
||||||
num_splines: u8,
|
num_splines: u8,
|
||||||
},
|
},
|
||||||
/// Frobnicate the rest
|
/// Frobnicate the rest
|
||||||
#[clap(visible_alias = "frob")]
|
#[command(visible_alias = "frob")]
|
||||||
Frobnicate,
|
Frobnicate,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ fn issue_490() {
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
opt_vec: Vec<u16>,
|
opt_vec: Vec<u16>,
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
opt_opt_vec: Option<Vec<u16>>,
|
opt_opt_vec: Option<Vec<u16>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ fn use_option() {
|
||||||
($name:ident: $ty:ty) => {
|
($name:ident: $ty:ty) => {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
struct Outer {
|
struct Outer {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
$name: $ty,
|
$name: $ty,
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ fn issue_447() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Command! {GitCmd, [
|
Command! {GitCmd, [
|
||||||
#[clap(external_subcommand)]
|
#[command(external_subcommand)]
|
||||||
Ext(Vec<String>)
|
Ext(Vec<String>)
|
||||||
]}
|
]}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ fn test_standalone_long_generates_kebab_case() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
FOO_OPTION: bool,
|
FOO_OPTION: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ fn test_standalone_long_generates_kebab_case() {
|
||||||
fn test_custom_long_overwrites_default_name() {
|
fn test_custom_long_overwrites_default_name() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long = "foo")]
|
#[arg(long = "foo")]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ fn test_custom_long_overwrites_default_name() {
|
||||||
fn test_standalone_long_uses_previous_defined_custom_name() {
|
fn test_standalone_long_uses_previous_defined_custom_name() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(name = "foo", long)]
|
#[arg(name = "foo", long)]
|
||||||
foo_option: bool,
|
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() {
|
fn test_standalone_long_ignores_afterwards_defined_custom_name() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long, name = "foo")]
|
#[arg(long, name = "foo")]
|
||||||
foo_option: bool,
|
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() {
|
fn test_standalone_long_uses_previous_defined_custom_id() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(id = "foo", long)]
|
#[arg(id = "foo", long)]
|
||||||
foo_option: bool,
|
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() {
|
fn test_standalone_long_ignores_afterwards_defined_custom_id() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long, id = "foo")]
|
#[arg(long, id = "foo")]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ fn test_standalone_short_generates_kebab_case() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
FOO_OPTION: bool,
|
FOO_OPTION: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ fn test_standalone_short_generates_kebab_case() {
|
||||||
fn test_custom_short_overwrites_default_name() {
|
fn test_custom_short_overwrites_default_name() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short = 'o')]
|
#[arg(short = 'o')]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ fn test_custom_short_overwrites_default_name() {
|
||||||
fn test_standalone_short_uses_previous_defined_custom_name() {
|
fn test_standalone_short_uses_previous_defined_custom_name() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(name = "option", short)]
|
#[arg(name = "option", short)]
|
||||||
foo_option: bool,
|
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() {
|
fn test_standalone_short_ignores_afterwards_defined_custom_name() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, name = "option")]
|
#[arg(short, name = "option")]
|
||||||
foo_option: bool,
|
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() {
|
fn test_standalone_short_uses_previous_defined_custom_id() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(id = "option", short)]
|
#[arg(id = "option", short)]
|
||||||
foo_option: bool,
|
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() {
|
fn test_standalone_short_ignores_afterwards_defined_custom_id() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, id = "option")]
|
#[arg(short, id = "option")]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ fn test_standalone_short_ignores_afterwards_defined_custom_id() {
|
||||||
fn test_standalone_long_uses_previous_defined_casing() {
|
fn test_standalone_long_uses_previous_defined_casing() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(rename_all = "screaming_snake", long)]
|
#[arg(rename_all = "screaming_snake", long)]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ fn test_standalone_long_uses_previous_defined_casing() {
|
||||||
fn test_standalone_short_uses_previous_defined_casing() {
|
fn test_standalone_short_uses_previous_defined_casing() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(rename_all = "screaming_snake", short)]
|
#[arg(rename_all = "screaming_snake", short)]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ fn test_standalone_long_works_with_verbatim_casing() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(rename_all = "verbatim", long)]
|
#[arg(rename_all = "verbatim", long)]
|
||||||
_fOO_oPtiON: bool,
|
_fOO_oPtiON: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ fn test_standalone_long_works_with_verbatim_casing() {
|
||||||
fn test_standalone_short_works_with_verbatim_casing() {
|
fn test_standalone_short_works_with_verbatim_casing() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(rename_all = "verbatim", short)]
|
#[arg(rename_all = "verbatim", short)]
|
||||||
_foo: bool,
|
_foo: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,9 +230,9 @@ fn test_standalone_short_works_with_verbatim_casing() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rename_all_is_propagated_from_struct_to_fields() {
|
fn test_rename_all_is_propagated_from_struct_to_fields() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[clap(rename_all = "screaming_snake")]
|
#[command(rename_all = "screaming_snake")]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,15 +245,15 @@ fn test_rename_all_is_propagated_from_struct_to_fields() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rename_all_is_not_propagated_from_struct_into_flattened() {
|
fn test_rename_all_is_not_propagated_from_struct_into_flattened() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[clap(rename_all = "screaming_snake")]
|
#[command(rename_all = "screaming_snake")]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(flatten)]
|
#[command(flatten)]
|
||||||
foo: Foo,
|
foo: Foo,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Foo {
|
struct Foo {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ fn test_rename_all_is_not_propagated_from_struct_into_flattened() {
|
||||||
fn test_lower_is_renamed() {
|
fn test_lower_is_renamed() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(rename_all = "lower", long)]
|
#[arg(rename_all = "lower", long)]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ fn test_lower_is_renamed() {
|
||||||
fn test_upper_is_renamed() {
|
fn test_upper_is_renamed() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(rename_all = "upper", long)]
|
#[arg(rename_all = "upper", long)]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,16 +322,16 @@ fn test_multi_word_enum_variant_is_renamed() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rename_all_is_not_propagated_from_struct_into_subcommand() {
|
fn test_rename_all_is_not_propagated_from_struct_into_subcommand() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[clap(rename_all = "screaming_snake")]
|
#[command(rename_all = "screaming_snake")]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
foo: Foo,
|
foo: Foo,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
enum Foo {
|
enum Foo {
|
||||||
Command {
|
Command {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo: bool,
|
foo: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -347,11 +347,11 @@ fn test_rename_all_is_not_propagated_from_struct_into_subcommand() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rename_all_is_propagated_from_enum_to_variants() {
|
fn test_rename_all_is_propagated_from_enum_to_variants() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[clap(rename_all = "screaming_snake")]
|
#[command(rename_all = "screaming_snake")]
|
||||||
enum Opt {
|
enum Opt {
|
||||||
FirstVariant,
|
FirstVariant,
|
||||||
SecondVariant {
|
SecondVariant {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo: String,
|
foo: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -365,11 +365,11 @@ fn test_rename_all_is_propagated_from_enum_to_variants() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rename_all_is_propagated_from_enum_to_variant_fields() {
|
fn test_rename_all_is_propagated_from_enum_to_variant_fields() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[clap(rename_all = "screaming_snake")]
|
#[command(rename_all = "screaming_snake")]
|
||||||
enum Opt {
|
enum Opt {
|
||||||
FirstVariant,
|
FirstVariant,
|
||||||
SecondVariant {
|
SecondVariant {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo: String,
|
foo: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -385,15 +385,15 @@ fn test_rename_all_is_propagated_from_enum_to_variant_fields() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rename_all_is_propagation_can_be_overridden() {
|
fn test_rename_all_is_propagation_can_be_overridden() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[clap(rename_all = "screaming_snake")]
|
#[command(rename_all = "screaming_snake")]
|
||||||
enum Opt {
|
enum Opt {
|
||||||
#[clap(rename_all = "kebab_case")]
|
#[command(rename_all = "kebab_case")]
|
||||||
FirstVariant {
|
FirstVariant {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
},
|
},
|
||||||
SecondVariant {
|
SecondVariant {
|
||||||
#[clap(rename_all = "kebab_case", long)]
|
#[arg(rename_all = "kebab_case", long)]
|
||||||
foo_option: bool,
|
foo_option: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,11 @@ use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
force: bool,
|
force: bool,
|
||||||
#[clap(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
verbose: u8,
|
verbose: u8,
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Sub,
|
cmd: Sub,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +32,11 @@ enum Sub {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt2 {
|
struct Opt2 {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
force: bool,
|
force: bool,
|
||||||
#[clap(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
verbose: u8,
|
verbose: u8,
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Option<Sub>,
|
cmd: Option<Sub>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,9 +109,9 @@ fn test_badinput() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt3 {
|
struct Opt3 {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
all: bool,
|
all: bool,
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Sub2,
|
cmd: Sub2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ struct Opt3 {
|
||||||
enum Sub2 {
|
enum Sub2 {
|
||||||
Foo {
|
Foo {
|
||||||
file: String,
|
file: String,
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Sub3,
|
cmd: Sub3,
|
||||||
},
|
},
|
||||||
Bar {},
|
Bar {},
|
||||||
|
@ -148,11 +148,11 @@ fn test_subsubcommand() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
enum SubSubCmdWithOption {
|
enum SubSubCmdWithOption {
|
||||||
Remote {
|
Remote {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Option<Remote>,
|
cmd: Option<Remote>,
|
||||||
},
|
},
|
||||||
Stash {
|
Stash {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Stash,
|
cmd: Stash,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ pub const DISPLAY_ORDER: usize = 2;
|
||||||
|
|
||||||
// Check if the global settings compile
|
// Check if the global settings compile
|
||||||
#[derive(Parser, Debug, PartialEq, Eq)]
|
#[derive(Parser, Debug, PartialEq, Eq)]
|
||||||
#[clap(allow_hyphen_values = true)]
|
#[command(allow_hyphen_values = true)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(
|
#[arg(
|
||||||
long = "x",
|
long = "x",
|
||||||
display_order = DISPLAY_ORDER,
|
display_order = DISPLAY_ORDER,
|
||||||
next_line_help = true,
|
next_line_help = true,
|
||||||
|
@ -31,13 +31,13 @@ struct Opt {
|
||||||
)]
|
)]
|
||||||
x: i32,
|
x: i32,
|
||||||
|
|
||||||
#[clap(short = 'l', long = "level", aliases = ["set-level", "lvl"])]
|
#[arg(short = 'l', long = "level", aliases = ["set-level", "lvl"])]
|
||||||
level: String,
|
level: String,
|
||||||
|
|
||||||
#[clap(long("values"))]
|
#[arg(long("values"))]
|
||||||
values: Vec<i32>,
|
values: Vec<i32>,
|
||||||
|
|
||||||
#[clap(name = "FILE", requires_if("FILE", "values"))]
|
#[arg(name = "FILE", requires_if("FILE", "values"))]
|
||||||
files: Vec<String>,
|
files: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ fn parse_hex(input: &str) -> Result<u64, ParseIntError> {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct HexOpt {
|
struct HexOpt {
|
||||||
#[clap(short, value_parser = parse_hex)]
|
#[arg(short, value_parser = parse_hex)]
|
||||||
number: u64,
|
number: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ use clap::{Parser, Subcommand};
|
||||||
fn required_option() {
|
fn required_option() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -48,7 +48,7 @@ fn required_option() {
|
||||||
fn option_with_default() {
|
fn option_with_default() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, default_value = "42")]
|
#[arg(short, default_value = "42")]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -66,7 +66,7 @@ fn option_with_default() {
|
||||||
fn option_with_raw_default() {
|
fn option_with_raw_default() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, default_value = "42")]
|
#[arg(short, default_value = "42")]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -148,7 +148,7 @@ fn option_vec_from_str() {
|
||||||
|
|
||||||
#[derive(Debug, Parser, PartialEq)]
|
#[derive(Debug, Parser, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
a: Option<Vec<A>>,
|
a: Option<Vec<A>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ fn option_vec_from_str() {
|
||||||
fn option_type_is_optional() {
|
fn option_type_is_optional() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
arg: Option<i32>,
|
arg: Option<i32>,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -180,19 +180,19 @@ fn option_type_is_optional() {
|
||||||
#[test]
|
#[test]
|
||||||
fn required_with_option_type() {
|
fn required_with_option_type() {
|
||||||
#[derive(Debug, PartialEq, Eq, Parser)]
|
#[derive(Debug, PartialEq, Eq, Parser)]
|
||||||
#[clap(subcommand_negates_reqs = true)]
|
#[command(subcommand_negates_reqs = true)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(required = true)]
|
#[arg(required = true)]
|
||||||
req_str: Option<String>,
|
req_str: Option<String>,
|
||||||
|
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
cmd: Option<SubCommands>,
|
cmd: Option<SubCommands>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Subcommand)]
|
#[derive(Debug, PartialEq, Eq, Subcommand)]
|
||||||
enum SubCommands {
|
enum SubCommands {
|
||||||
ExSub {
|
ExSub {
|
||||||
#[clap(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
verbose: u8,
|
verbose: u8,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ fn ignore_qualified_option_type() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_parser = parser)]
|
#[arg(value_parser = parser)]
|
||||||
arg: ::std::option::Option<String>,
|
arg: ::std::option::Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ fn ignore_qualified_option_type() {
|
||||||
fn option_option_type_is_optional_value() {
|
fn option_option_type_is_optional_value() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
#[allow(clippy::option_option)]
|
#[allow(clippy::option_option)]
|
||||||
arg: Option<Option<i32>>,
|
arg: Option<Option<i32>>,
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ fn option_option_type_is_optional_value() {
|
||||||
fn option_option_type_help() {
|
fn option_option_type_help() {
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long, value_name = "val")]
|
#[arg(long, value_name = "val")]
|
||||||
arg: Option<Option<i32>>,
|
arg: Option<Option<i32>>,
|
||||||
}
|
}
|
||||||
let help = utils::get_help::<Opt>();
|
let help = utils::get_help::<Opt>();
|
||||||
|
@ -279,10 +279,10 @@ fn option_option_type_help() {
|
||||||
fn two_option_option_types() {
|
fn two_option_option_types() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
arg: Option<Option<i32>>,
|
arg: Option<Option<i32>>,
|
||||||
|
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
field: Option<Option<String>>,
|
field: Option<Option<String>>,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -333,7 +333,7 @@ fn two_option_option_types() {
|
||||||
fn vec_type_is_multiple_occurrences() {
|
fn vec_type_is_multiple_occurrences() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
arg: Vec<i32>,
|
arg: Vec<i32>,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -351,7 +351,7 @@ fn vec_type_is_multiple_occurrences() {
|
||||||
fn vec_type_with_required() {
|
fn vec_type_with_required() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long, required = true)]
|
#[arg(short, long, required = true)]
|
||||||
arg: Vec<i32>,
|
arg: Vec<i32>,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -369,7 +369,7 @@ fn vec_type_with_required() {
|
||||||
fn vec_type_with_multiple_values_only() {
|
fn vec_type_with_multiple_values_only() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long, num_args(1..))]
|
#[arg(short, long, num_args(1..))]
|
||||||
arg: Vec<i32>,
|
arg: Vec<i32>,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -391,7 +391,7 @@ fn ignore_qualified_vec_type() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_parser = parser)]
|
#[arg(value_parser = parser)]
|
||||||
arg: ::std::vec::Vec<String>,
|
arg: ::std::vec::Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ fn ignore_qualified_vec_type() {
|
||||||
fn option_vec_type() {
|
fn option_vec_type() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
arg: Option<Vec<i32>>,
|
arg: Option<Vec<i32>>,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -429,7 +429,7 @@ fn option_vec_type() {
|
||||||
fn option_vec_type_structopt_behavior() {
|
fn option_vec_type_structopt_behavior() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long, num_args(0..))]
|
#[arg(short, long, num_args(0..))]
|
||||||
arg: Option<Vec<i32>>,
|
arg: Option<Vec<i32>>,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -456,10 +456,10 @@ fn option_vec_type_structopt_behavior() {
|
||||||
fn two_option_vec_types() {
|
fn two_option_vec_types() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
arg: Option<Vec<i32>>,
|
arg: Option<Vec<i32>>,
|
||||||
|
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
b: Option<Vec<i32>>,
|
b: Option<Vec<i32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ fn two_option_vec_types() {
|
||||||
fn explicit_value_parser() {
|
fn explicit_value_parser() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long, value_parser = clap::value_parser!(i32))]
|
#[arg(long, value_parser = clap::value_parser!(i32))]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -510,7 +510,7 @@ fn explicit_value_parser() {
|
||||||
fn implicit_value_parser() {
|
fn implicit_value_parser() {
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
arg: i32,
|
arg: i32,
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -17,7 +17,7 @@ mod options {
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
pub subcommand: super::subcommands::SubCommand,
|
pub subcommand: super::subcommands::SubCommand,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@ use clap::Parser;
|
||||||
#[test]
|
#[test]
|
||||||
fn raw_bool_literal() {
|
fn raw_bool_literal() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
#[clap(name = "raw_bool")]
|
#[command(name = "raw_bool")]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(raw(false))]
|
#[arg(raw(false))]
|
||||||
a: String,
|
a: String,
|
||||||
#[clap(raw(true))]
|
#[arg(raw(true))]
|
||||||
b: String,
|
b: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use clap::Parser;
|
||||||
fn raw_idents() {
|
fn raw_idents() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
r#type: String,
|
r#type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ use clap::Parser;
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn it_works() {
|
||||||
#[derive(Debug, PartialEq, Parser)]
|
#[derive(Debug, PartialEq, Parser)]
|
||||||
#[clap(rename_all_env = "kebab")]
|
#[command(rename_all_env = "kebab")]
|
||||||
struct BehaviorModel {
|
struct BehaviorModel {
|
||||||
#[clap(env)]
|
#[arg(env)]
|
||||||
be_nice: String,
|
be_nice: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ fn it_works() {
|
||||||
fn default_is_screaming() {
|
fn default_is_screaming() {
|
||||||
#[derive(Debug, PartialEq, Parser)]
|
#[derive(Debug, PartialEq, Parser)]
|
||||||
struct BehaviorModel {
|
struct BehaviorModel {
|
||||||
#[clap(env)]
|
#[arg(env)]
|
||||||
be_nice: String,
|
be_nice: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ fn default_is_screaming() {
|
||||||
#[test]
|
#[test]
|
||||||
fn overridable() {
|
fn overridable() {
|
||||||
#[derive(Debug, PartialEq, Parser)]
|
#[derive(Debug, PartialEq, Parser)]
|
||||||
#[clap(rename_all_env = "kebab")]
|
#[command(rename_all_env = "kebab")]
|
||||||
struct BehaviorModel {
|
struct BehaviorModel {
|
||||||
#[clap(env)]
|
#[arg(env)]
|
||||||
be_nice: String,
|
be_nice: String,
|
||||||
|
|
||||||
#[clap(rename_all_env = "pascal", env)]
|
#[arg(rename_all_env = "pascal", env)]
|
||||||
be_aggressive: String,
|
be_aggressive: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ use clap::Parser;
|
||||||
fn skip_1() {
|
fn skip_1() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
x: u32,
|
x: u32,
|
||||||
#[clap(skip)]
|
#[arg(skip)]
|
||||||
s: u32,
|
s: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,15 +39,15 @@ fn skip_1() {
|
||||||
fn skip_2() {
|
fn skip_2() {
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
x: u32,
|
x: u32,
|
||||||
#[clap(skip)]
|
#[arg(skip)]
|
||||||
ss: String,
|
ss: String,
|
||||||
#[clap(skip)]
|
#[arg(skip)]
|
||||||
sn: u8,
|
sn: u8,
|
||||||
|
|
||||||
y: u32,
|
y: u32,
|
||||||
#[clap(skip)]
|
#[arg(skip)]
|
||||||
sz: u16,
|
sz: u16,
|
||||||
|
|
||||||
t: u32,
|
t: u32,
|
||||||
|
@ -83,11 +83,11 @@ fn skip_enum() {
|
||||||
|
|
||||||
#[derive(Parser, Debug, PartialEq)]
|
#[derive(Parser, Debug, PartialEq)]
|
||||||
pub struct Opt {
|
pub struct Opt {
|
||||||
#[clap(long, short)]
|
#[arg(long, short)]
|
||||||
number: u32,
|
number: u32,
|
||||||
#[clap(skip)]
|
#[arg(skip)]
|
||||||
k: Kind,
|
k: Kind,
|
||||||
#[clap(skip)]
|
#[arg(skip)]
|
||||||
v: Vec<u32>,
|
v: Vec<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,19 +105,19 @@ fn skip_enum() {
|
||||||
fn skip_help_doc_comments() {
|
fn skip_help_doc_comments() {
|
||||||
#[derive(Parser, Debug, PartialEq, Eq)]
|
#[derive(Parser, Debug, PartialEq, Eq)]
|
||||||
pub struct Opt {
|
pub struct Opt {
|
||||||
#[clap(skip, help = "internal_stuff")]
|
#[arg(skip, help = "internal_stuff")]
|
||||||
a: u32,
|
a: u32,
|
||||||
|
|
||||||
#[clap(skip, long_help = "internal_stuff\ndo not touch")]
|
#[arg(skip, long_help = "internal_stuff\ndo not touch")]
|
||||||
b: u32,
|
b: u32,
|
||||||
|
|
||||||
/// Not meant to be used by clap.
|
/// Not meant to be used by clap.
|
||||||
///
|
///
|
||||||
/// I want a default here.
|
/// I want a default here.
|
||||||
#[clap(skip)]
|
#[arg(skip)]
|
||||||
c: u32,
|
c: u32,
|
||||||
|
|
||||||
#[clap(short)]
|
#[arg(short)]
|
||||||
n: u32,
|
n: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,13 +136,13 @@ fn skip_help_doc_comments() {
|
||||||
fn skip_val() {
|
fn skip_val() {
|
||||||
#[derive(Parser, Debug, PartialEq, Eq)]
|
#[derive(Parser, Debug, PartialEq, Eq)]
|
||||||
pub struct Opt {
|
pub struct Opt {
|
||||||
#[clap(long, short)]
|
#[arg(long, short)]
|
||||||
number: u32,
|
number: u32,
|
||||||
|
|
||||||
#[clap(skip = "key")]
|
#[arg(skip = "key")]
|
||||||
k: String,
|
k: String,
|
||||||
|
|
||||||
#[clap(skip = vec![1, 2, 3])]
|
#[arg(skip = vec![1, 2, 3])]
|
||||||
v: Vec<u32>,
|
v: Vec<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,19 +20,19 @@ use clap::{Args, Parser, Subcommand};
|
||||||
enum Opt {
|
enum Opt {
|
||||||
/// Fetch stuff from GitHub
|
/// Fetch stuff from GitHub
|
||||||
Fetch {
|
Fetch {
|
||||||
#[clap(long)]
|
#[arg(long)]
|
||||||
all: bool,
|
all: bool,
|
||||||
/// Overwrite local branches.
|
/// Overwrite local branches.
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
force: bool,
|
force: bool,
|
||||||
|
|
||||||
repo: String,
|
repo: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
Add {
|
Add {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
interactive: bool,
|
interactive: bool,
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ fn test_null_commands() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
#[clap(about = "Not shown")]
|
#[command(about = "Not shown")]
|
||||||
struct Add {
|
struct Add {
|
||||||
file: String,
|
file: String,
|
||||||
}
|
}
|
||||||
|
@ -168,9 +168,9 @@ fn test_tuple_commands() {
|
||||||
fn global_passed_down() {
|
fn global_passed_down() {
|
||||||
#[derive(Debug, PartialEq, Eq, Parser)]
|
#[derive(Debug, PartialEq, Eq, Parser)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(global = true, long)]
|
#[arg(global = true, long)]
|
||||||
other: bool,
|
other: bool,
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
sub: Subcommands,
|
sub: Subcommands,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ fn global_passed_down() {
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Args)]
|
#[derive(Debug, PartialEq, Eq, Args)]
|
||||||
struct GlobalCmd {
|
struct GlobalCmd {
|
||||||
#[clap(from_global)]
|
#[arg(from_global)]
|
||||||
other: bool,
|
other: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ fn global_passed_down() {
|
||||||
fn external_subcommand() {
|
fn external_subcommand() {
|
||||||
#[derive(Debug, PartialEq, Eq, Parser)]
|
#[derive(Debug, PartialEq, Eq, Parser)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
sub: Subcommands,
|
sub: Subcommands,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ fn external_subcommand() {
|
||||||
enum Subcommands {
|
enum Subcommands {
|
||||||
Add,
|
Add,
|
||||||
Remove,
|
Remove,
|
||||||
#[clap(external_subcommand)]
|
#[command(external_subcommand)]
|
||||||
Other(Vec<String>),
|
Other(Vec<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,13 +249,13 @@ fn external_subcommand_os_string() {
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Parser)]
|
#[derive(Debug, PartialEq, Eq, Parser)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
sub: Subcommands,
|
sub: Subcommands,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Subcommand)]
|
#[derive(Debug, PartialEq, Eq, Subcommand)]
|
||||||
enum Subcommands {
|
enum Subcommands {
|
||||||
#[clap(external_subcommand)]
|
#[command(external_subcommand)]
|
||||||
Other(Vec<OsString>),
|
Other(Vec<OsString>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,13 +273,13 @@ fn external_subcommand_os_string() {
|
||||||
fn external_subcommand_optional() {
|
fn external_subcommand_optional() {
|
||||||
#[derive(Debug, PartialEq, Eq, Parser)]
|
#[derive(Debug, PartialEq, Eq, Parser)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
sub: Option<Subcommands>,
|
sub: Option<Subcommands>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Subcommand)]
|
#[derive(Debug, PartialEq, Eq, Subcommand)]
|
||||||
enum Subcommands {
|
enum Subcommands {
|
||||||
#[clap(external_subcommand)]
|
#[command(external_subcommand)]
|
||||||
Other(Vec<String>),
|
Other(Vec<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,9 +297,9 @@ fn external_subcommand_optional() {
|
||||||
fn enum_in_enum_subsubcommand() {
|
fn enum_in_enum_subsubcommand() {
|
||||||
#[derive(Parser, Debug, PartialEq, Eq)]
|
#[derive(Parser, Debug, PartialEq, Eq)]
|
||||||
pub enum Opt {
|
pub enum Opt {
|
||||||
#[clap(alias = "l")]
|
#[command(alias = "l")]
|
||||||
List,
|
List,
|
||||||
#[clap(subcommand, alias = "d")]
|
#[command(subcommand, alias = "d")]
|
||||||
Daemon(DaemonCommand),
|
Daemon(DaemonCommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,9 +378,9 @@ fn update_subcommands() {
|
||||||
fn update_sub_subcommands() {
|
fn update_sub_subcommands() {
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
enum Opt {
|
enum Opt {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
Child1(Child1),
|
Child1(Child1),
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
Child2(Child2),
|
Child2(Child2),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ fn update_ext_subcommand() {
|
||||||
enum Opt {
|
enum Opt {
|
||||||
Command1(Command1),
|
Command1(Command1),
|
||||||
Command2(Command2),
|
Command2(Command2),
|
||||||
#[clap(external_subcommand)]
|
#[command(external_subcommand)]
|
||||||
Ext(Vec<String>),
|
Ext(Vec<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,13 +503,13 @@ fn subcommand_name_not_literal() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Eq, Debug)]
|
#[derive(Parser, PartialEq, Eq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
subcmd: SubCmd,
|
subcmd: SubCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand, PartialEq, Eq, Debug)]
|
#[derive(Subcommand, PartialEq, Eq, Debug)]
|
||||||
enum SubCmd {
|
enum SubCmd {
|
||||||
#[clap(name = get_name())]
|
#[command(name = get_name())]
|
||||||
SubCmd1,
|
SubCmd1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ fn subcommand_name_not_literal() {
|
||||||
fn skip_subcommand() {
|
fn skip_subcommand() {
|
||||||
#[derive(Debug, PartialEq, Eq, Parser)]
|
#[derive(Debug, PartialEq, Eq, Parser)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
sub: Subcommands,
|
sub: Subcommands,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +530,7 @@ fn skip_subcommand() {
|
||||||
Remove,
|
Remove,
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[clap(skip)]
|
#[command(skip)]
|
||||||
Skip,
|
Skip,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ fn built_in_subcommand_escaped() {
|
||||||
Install {
|
Install {
|
||||||
arg: Option<String>,
|
arg: Option<String>,
|
||||||
},
|
},
|
||||||
#[clap(external_subcommand)]
|
#[command(external_subcommand)]
|
||||||
Custom(Vec<String>),
|
Custom(Vec<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ type Option<T> = std::option::Option<T>;
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
pub struct Opts {
|
pub struct Opts {
|
||||||
another_string: String,
|
another_string: String,
|
||||||
#[clap(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Command,
|
command: Command,
|
||||||
#[clap(short, long, value_enum)]
|
#[arg(short, long, value_enum)]
|
||||||
choice: ArgChoice,
|
choice: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct Positional {
|
||||||
|
|
||||||
#[derive(Parser, Debug, PartialEq, Eq)]
|
#[derive(Parser, Debug, PartialEq, Eq)]
|
||||||
struct Named {
|
struct Named {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
arg: String,
|
arg: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ struct PositionalOs {
|
||||||
|
|
||||||
#[derive(Parser, Debug, PartialEq, Eq)]
|
#[derive(Parser, Debug, PartialEq, Eq)]
|
||||||
struct NamedOs {
|
struct NamedOs {
|
||||||
#[clap(short, long)]
|
#[arg(short, long)]
|
||||||
arg: OsString,
|
arg: OsString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ fn invalid_utf8_option_long_equals() {
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Parser)]
|
#[derive(Debug, PartialEq, Parser)]
|
||||||
enum External {
|
enum External {
|
||||||
#[clap(external_subcommand)]
|
#[command(external_subcommand)]
|
||||||
Other(Vec<String>),
|
Other(Vec<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ fn refuse_invalid_utf8_subcommand_args_with_allow_external_subcommands() {
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Parser)]
|
#[derive(Debug, PartialEq, Parser)]
|
||||||
enum ExternalOs {
|
enum ExternalOs {
|
||||||
#[clap(external_subcommand)]
|
#[command(external_subcommand)]
|
||||||
Other(Vec<OsString>),
|
Other(Vec<OsString>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ fn basic() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum)]
|
#[arg(value_enum)]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ fn default_value() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum, default_value_t)]
|
#[arg(value_enum, default_value_t)]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +88,10 @@ fn vec_for_default_values_t() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
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>,
|
arg1: Vec<ArgChoice>,
|
||||||
|
|
||||||
#[clap(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
value_enum,
|
value_enum,
|
||||||
default_values_t = clap::ValueEnum::value_variants()
|
default_values_t = clap::ValueEnum::value_variants()
|
||||||
|
@ -139,10 +139,10 @@ fn vec_for_default_values_os_t() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
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>,
|
arg: Vec<ArgChoice>,
|
||||||
|
|
||||||
#[clap(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
value_enum,
|
value_enum,
|
||||||
default_values_os_t = clap::ValueEnum::value_variants()
|
default_values_os_t = clap::ValueEnum::value_variants()
|
||||||
|
@ -191,7 +191,7 @@ fn multi_word_is_renamed_kebab() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum)]
|
#[arg(value_enum)]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,13 +214,13 @@ fn multi_word_is_renamed_kebab() {
|
||||||
fn variant_with_defined_casing() {
|
fn variant_with_defined_casing() {
|
||||||
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
||||||
enum ArgChoice {
|
enum ArgChoice {
|
||||||
#[clap(rename_all = "screaming_snake")]
|
#[value(rename_all = "screaming_snake")]
|
||||||
FooBar,
|
FooBar,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum)]
|
#[arg(value_enum)]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,14 +236,14 @@ fn variant_with_defined_casing() {
|
||||||
#[test]
|
#[test]
|
||||||
fn casing_is_propagated_from_parent() {
|
fn casing_is_propagated_from_parent() {
|
||||||
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
||||||
#[clap(rename_all = "screaming_snake")]
|
#[value(rename_all = "screaming_snake")]
|
||||||
enum ArgChoice {
|
enum ArgChoice {
|
||||||
FooBar,
|
FooBar,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum)]
|
#[arg(value_enum)]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,15 +259,15 @@ fn casing_is_propagated_from_parent() {
|
||||||
#[test]
|
#[test]
|
||||||
fn casing_propagation_is_overridden() {
|
fn casing_propagation_is_overridden() {
|
||||||
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
||||||
#[clap(rename_all = "screaming_snake")]
|
#[value(rename_all = "screaming_snake")]
|
||||||
enum ArgChoice {
|
enum ArgChoice {
|
||||||
#[clap(rename_all = "camel")]
|
#[value(rename_all = "camel")]
|
||||||
FooBar,
|
FooBar,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum)]
|
#[arg(value_enum)]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ fn ignore_case() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum, ignore_case(true))]
|
#[arg(value_enum, ignore_case(true))]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ fn ignore_case_set_to_false() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum, ignore_case(false))]
|
#[arg(value_enum, ignore_case(false))]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,13 +334,13 @@ fn ignore_case_set_to_false() {
|
||||||
fn alias() {
|
fn alias() {
|
||||||
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
||||||
enum ArgChoice {
|
enum ArgChoice {
|
||||||
#[clap(alias = "TOTP")]
|
#[value(alias = "TOTP")]
|
||||||
Totp,
|
Totp,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum, ignore_case(false))]
|
#[arg(value_enum, ignore_case(false))]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,13 +362,13 @@ fn alias() {
|
||||||
fn multiple_alias() {
|
fn multiple_alias() {
|
||||||
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
|
||||||
enum ArgChoice {
|
enum ArgChoice {
|
||||||
#[clap(alias = "TOTP", alias = "t")]
|
#[value(alias = "TOTP", alias = "t")]
|
||||||
Totp,
|
Totp,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum, ignore_case(false))]
|
#[arg(value_enum, ignore_case(false))]
|
||||||
arg: ArgChoice,
|
arg: ArgChoice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +399,7 @@ fn skip_variant() {
|
||||||
enum ArgChoice {
|
enum ArgChoice {
|
||||||
Foo,
|
Foo,
|
||||||
Bar,
|
Bar,
|
||||||
#[clap(skip)]
|
#[value(skip)]
|
||||||
Baz,
|
Baz,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ fn skip_non_unit_variant() {
|
||||||
enum ArgChoice {
|
enum ArgChoice {
|
||||||
Foo,
|
Foo,
|
||||||
Bar,
|
Bar,
|
||||||
#[clap(skip)]
|
#[value(skip)]
|
||||||
Baz(usize),
|
Baz(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ fn option_type() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum)]
|
#[arg(value_enum)]
|
||||||
arg: Option<ArgChoice>,
|
arg: Option<ArgChoice>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ fn option_option_type() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum, long)]
|
#[arg(value_enum, long)]
|
||||||
arg: Option<Option<ArgChoice>>,
|
arg: Option<Option<ArgChoice>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ fn vec_type() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum, short, long)]
|
#[arg(value_enum, short, long)]
|
||||||
arg: Vec<ArgChoice>,
|
arg: Vec<ArgChoice>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ fn option_vec_type() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(value_enum, short, long)]
|
#[arg(value_enum, short, long)]
|
||||||
arg: Option<Vec<ArgChoice>>,
|
arg: Option<Vec<ArgChoice>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ fn vec_type_default_value() {
|
||||||
|
|
||||||
#[derive(Parser, PartialEq, Debug)]
|
#[derive(Parser, PartialEq, Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[clap(
|
#[arg(
|
||||||
value_enum,
|
value_enum,
|
||||||
short,
|
short,
|
||||||
long,
|
long,
|
||||||
|
|
Loading…
Reference in a new issue