pub enum ColorChoice {
Never,
Auto,
Always,
}Expand description
Possible color choices for the output.
§Clap interoperability
If the clap feature is enabled then
ColorChoice can be converted to and from clap::ColorChoice.
Moreover it implements clap::ValueEnum, hence can be used as
#[derive(clap::Parser)]
struct Cli {
/// Coloring of the output
#[clap(long, value_name = "WHEN", arg_enum, global = true)]
color: Option<should_color::ColorChoice>,
// Other arguments...
}Variants§
Never
The output will not be colorized.
Auto
The output will be colorized if the output device is a tty, i.e. when the output goes directly to a text screen or terminal emulator window.
Always
The output will be colorized.
Implementations§
Source§impl ColorChoice
impl ColorChoice
Sourcepub fn for_stream(&self, stream: Stream) -> bool
Available on crate feature stream only.
pub fn for_stream(&self, stream: Stream) -> bool
stream only.Determine the color setting for a specific stream.
If the choice is ColorChoice::Never or ColorChoice::Always,
the result will be false and true respectively.
If the choice is ColorChoice::Auto, then the answer depends on whether
the stream is a TTY or not.
See the examples colored.rs and termcolor.rs for a demonstration of how to use this method.
Trait Implementations§
Source§impl Clone for ColorChoice
impl Clone for ColorChoice
Source§fn clone(&self) -> ColorChoice
fn clone(&self) -> ColorChoice
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ColorChoice
impl Debug for ColorChoice
Source§impl From<ColorChoice> for ColorChoice
Available on crate feature clap only.
impl From<ColorChoice> for ColorChoice
Available on crate feature
clap only.Source§fn from(color_choice: ColorChoice) -> ColorChoice
fn from(color_choice: ColorChoice) -> ColorChoice
Converts to this type from the input type.
Source§impl From<ColorChoice> for ColorChoice
Available on crate feature clap only.
impl From<ColorChoice> for ColorChoice
Available on crate feature
clap only.Source§fn from(color_choice: ColorChoice) -> ColorChoice
fn from(color_choice: ColorChoice) -> ColorChoice
Converts to this type from the input type.
Source§impl Ord for ColorChoice
impl Ord for ColorChoice
Source§fn cmp(&self, other: &ColorChoice) -> Ordering
fn cmp(&self, other: &ColorChoice) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ColorChoice
impl PartialEq for ColorChoice
Source§impl PartialOrd for ColorChoice
impl PartialOrd for ColorChoice
Source§impl ValueEnum for ColorChoice
impl ValueEnum for ColorChoice
impl Copy for ColorChoice
impl Eq for ColorChoice
impl StructuralPartialEq for ColorChoice
Auto Trait Implementations§
impl Freeze for ColorChoice
impl RefUnwindSafe for ColorChoice
impl Send for ColorChoice
impl Sync for ColorChoice
impl Unpin for ColorChoice
impl UnwindSafe for ColorChoice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.