use clap::Subcommand;
#[derive(Clone, Debug)]
pub enum Protocol {
Json,
}
impl Protocol {
fn as_str(&self) -> &'static str {
match self {
Self::Json => "JSON",
}
}
}
impl clap::ValueEnum for Protocol {
fn value_variants<'a>() -> &'a [Self] {
&[Self::Json]
}
fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
match self {
Self::Json => Some(clap::builder::PossibleValue::new("JSON")),
}
}
}
#[derive(Subcommand, Debug)]
pub enum Integrations {
Add {
name: String,
endpoint: String,
protocol: Protocol,
},
}
impl Integrations {
pub fn handle(&self, project: &str) -> anyhow::Result<()> {
match self {
Self::Add {
name,
endpoint,
protocol,
} => {
ordinary_modify::add_integration(project, name, endpoint, protocol.as_str())?;
}
}
Ok(())
}
}