Enum ColorChoice

pub enum ColorChoice

Represents the color preferences for program output

Variants

Auto

Enables colored output only when the output is going to a terminal or TTY.

NOTE: This is the default behavior of clap.

Examples

# #[cfg(feature = "color")] {
# use clap_builder as clap;
# use clap::{Command, ColorChoice};
Command::new("myprog")
    .color(ColorChoice::Auto)
    .get_matches();
# }
Always

Enables colored output regardless of whether or not the output is going to a terminal/TTY.

Examples

# #[cfg(feature = "color")] {
# use clap_builder as clap;
# use clap::{Command, ColorChoice};
Command::new("myprog")
    .color(ColorChoice::Always)
    .get_matches();
# }
Never

Disables colored output no matter if the output is going to a terminal/TTY, or not.

Examples

# #[cfg(feature = "color")] {
# use clap_builder as clap;
# use clap::{Command, ColorChoice};
Command::new("myprog")
    .color(ColorChoice::Never)
    .get_matches();
# }

Implementations

impl ColorChoice

fn possible_values() -> impl Iterator<Item = PossibleValue>

Report all possible_values

Trait Implementations

impl Clone for ColorChoice

fn clone(&self) -> ColorChoice

impl Copy for ColorChoice

impl Debug for ColorChoice

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Default for ColorChoice

fn default() -> ColorChoice

impl Display for ColorChoice

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Eq for ColorChoice

impl FromStr for ColorChoice

type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err>

impl PartialEq for ColorChoice

fn eq(&self, other: &ColorChoice) -> bool

impl StructuralPartialEq for ColorChoice

impl ValueEnum for ColorChoice

fn value_variants<'a>() -> &'a [Self]
fn to_possible_value(&self) -> Option<PossibleValue>

Auto Trait Implementations

impl Freeze for ColorChoice

impl RefUnwindSafe for ColorChoice

impl Send for ColorChoice

impl Sync for ColorChoice

impl Unpin for ColorChoice

impl UnsafeUnpin for ColorChoice

impl UnwindSafe for ColorChoice

Blanket Implementations

impl<T> Any for ColorChoice where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for ColorChoice where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for ColorChoice where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for ColorChoice where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for ColorChoice

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for ColorChoice where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for ColorChoice where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for ColorChoice where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for ColorChoice where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for ColorChoice where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>