Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clap_builder/src/builder/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ impl Arg {
///
/// <div class="warning">
///
/// **NOTE:** When utilized with [`Arg::num_args(1..)`], only the **last** positional argument
/// **NOTE:** When utilized with [`Arg::num_args(1..)`][Arg::num_args], only the **last** positional argument
/// may be defined as having a variable number of arguments (i.e. with the highest index)
///
/// </div>
Expand Down Expand Up @@ -1359,7 +1359,7 @@ impl Arg {
///
/// <div class="warning">
///
/// **NOTE:** implicitly sets [`Arg::action(ArgAction::Set)`].
/// **NOTE:** implicitly sets [`Arg::action(ArgAction::Set)`][ArgAction::Set].
///
/// </div>
///
Expand Down Expand Up @@ -1487,7 +1487,7 @@ impl Arg {
///
/// **WARNING:** Prior arguments with `allow_hyphen_values(true)` get precedence over known
/// flags but known flags get precedence over the next possible positional argument with
/// `allow_hyphen_values(true)`. When combined with [`Arg::num_args(..)`],
/// `allow_hyphen_values(true)`. When combined with [`Arg::num_args(..)`][Arg::num_args],
/// [`Arg::value_terminator`] is one way to ensure processing stops.
///
/// </div>
Expand Down
2 changes: 1 addition & 1 deletion clap_builder/src/error/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub enum ErrorKind {
/// Occurs when the user provides a value containing invalid UTF-8.
///
/// To allow arbitrary data
/// - Set [`Arg::value_parser(value_parser!(OsString))`] for argument values
/// - Set [`Arg::value_parser(value_parser!(OsString))`][crate::Arg::value_parser] for argument values
/// - Set [`Command::external_subcommand_value_parser`] for external-subcommand
/// values
///
Expand Down
9 changes: 2 additions & 7 deletions clap_builder/src/util/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::builder::PossibleValue;
use crate::derive::ValueEnum;

/// Represents the color preferences for program output
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
pub enum ColorChoice {
/// Enables colored output only when the output is going to a terminal or TTY.
///
Expand All @@ -23,6 +23,7 @@ pub enum ColorChoice {
/// .get_matches();
/// # }
/// ```
#[default]
Auto,

/// Enables colored output regardless of whether or not the output is going to a terminal/TTY.
Expand Down Expand Up @@ -65,12 +66,6 @@ impl ColorChoice {
}
}

impl Default for ColorChoice {
fn default() -> Self {
Self::Auto
}
}

impl std::fmt::Display for ColorChoice {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.to_possible_value()
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_builder/04_04_custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
)
.exit();
}
ver.to_string()
ver.clone()
} else {
// Increment the one requested (in a real program, we'd reset the lower numbers)
let (maj, min, pat) = (
Expand Down
8 changes: 3 additions & 5 deletions tests/derive/value_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ fn basic() {
#[test]
fn default_value() {
#[derive(clap::ValueEnum, PartialEq, Debug, Clone)]
#[derive(Default)]
enum ArgChoice {
Foo,
#[default]
Bar,
}

impl Default for ArgChoice {
fn default() -> Self {
Self::Bar
}
}


#[derive(Parser, PartialEq, Debug)]
struct Opt {
Expand Down