mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
Merge pull request #4978 from clap-rs/colorchoice-values
Improve colorchoice enum
This commit is contained in:
commit
4aff61dd01
1 changed files with 12 additions and 5 deletions
|
@ -64,6 +64,15 @@ pub enum ColorChoice {
|
||||||
Never,
|
Never,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ColorChoice {
|
||||||
|
/// Report all `possible_values`
|
||||||
|
pub fn possible_values() -> impl Iterator<Item = PossibleValue> {
|
||||||
|
Self::value_variants()
|
||||||
|
.iter()
|
||||||
|
.filter_map(ValueEnum::to_possible_value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for ColorChoice {
|
impl Default for ColorChoice {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::Auto
|
Self::Auto
|
||||||
|
@ -99,11 +108,9 @@ impl ValueEnum for ColorChoice {
|
||||||
|
|
||||||
fn to_possible_value(&self) -> Option<PossibleValue> {
|
fn to_possible_value(&self) -> Option<PossibleValue> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
Self::Auto => {
|
Self::Auto => PossibleValue::new("auto"),
|
||||||
PossibleValue::new("auto").help("Use colored output if writing to a terminal/TTY")
|
Self::Always => PossibleValue::new("always"),
|
||||||
}
|
Self::Never => PossibleValue::new("never"),
|
||||||
Self::Always => PossibleValue::new("always").help("Always use colored output"),
|
|
||||||
Self::Never => PossibleValue::new("never").help("Never use colored output"),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue