ordinary 0.6.0-pre.9

Ordinary CLI
Documentation
// Copyright (C) 2026 Ordinary Labs, LLC.
//
// SPDX-License-Identifier: AGPL-3.0-only

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 a new integration to your Ordinary project
    Add {
        /// name of the integration
        name: String,

        /// url endpoint for integration
        endpoint: String,

        /// protocol for the integration
        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(())
    }
}