mirror of https://github.com/msfjarvis/adx.git
feat(adx): restore support for single character alias
This commit is contained in:
parent
439adc6880
commit
2589087822
|
@ -1,3 +1,4 @@
|
|||
use clap::builder::PossibleValue;
|
||||
use clap::ValueEnum;
|
||||
use semver::{Prerelease, Version};
|
||||
use std::cmp::{Eq, PartialEq, PartialOrd};
|
||||
|
@ -10,7 +11,7 @@ use thiserror::Error;
|
|||
/// Since we're deriving `PartialOrd` automatically, the order
|
||||
/// of these fields is crucial. Sort by stability, not alphabetical
|
||||
/// order.
|
||||
#[derive(Debug, Eq, PartialEq, PartialOrd, Clone, Copy, ValueEnum)]
|
||||
#[derive(Debug, Eq, PartialEq, PartialOrd, Clone, Copy)]
|
||||
pub(crate) enum Channel {
|
||||
Dev,
|
||||
Alpha,
|
||||
|
@ -19,6 +20,22 @@ pub(crate) enum Channel {
|
|||
Stable,
|
||||
}
|
||||
|
||||
impl ValueEnum for Channel {
|
||||
fn value_variants<'a>() -> &'a [Self] {
|
||||
&[Self::Dev, Self::Alpha, Self::Beta, Self::Rc, Self::Stable]
|
||||
}
|
||||
|
||||
fn to_possible_value(&self) -> Option<PossibleValue> {
|
||||
match self {
|
||||
Channel::Dev => Some(PossibleValue::new("dev").alias("d")),
|
||||
Channel::Alpha => Some(PossibleValue::new("alpha").alias("a")),
|
||||
Channel::Beta => Some(PossibleValue::new("beta").alias("b")),
|
||||
Channel::Stable => Some(PossibleValue::new("stable").alias("s")),
|
||||
Channel::Rc => Some(PossibleValue::new("rc").alias("r")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub(crate) enum ChannelError {
|
||||
#[error("no match found")]
|
||||
|
|
Loading…
Reference in New Issue