ordinary 0.13.0

Ordinary CLI
Documentation
use crate::HostCallFlags;
use crate::cmds::accounts::get_current_account;
use clap::Subcommand;
use saferlmdb::Environment;
use std::sync::Arc;
use tracing::instrument;

#[derive(Subcommand, Debug)]
pub enum Secrets {
    /// store a host secret
    Store {
        #[command(flatten)]
        host: HostCallFlags,

        /// secret name
        name: String,
        // todo: also be able to load this from a file
        // todo: or environment
        /// secret value
        secret: String,
    },
}

impl Secrets {
    #[instrument(skip_all, name = "secrets")]
    pub async fn handle(&self, project: &str, env: &Arc<Environment>) -> anyhow::Result<()> {
        match self {
            Self::Store { name, secret, host } => {
                let account = get_current_account()?;
                let client = host.client(&account, env)?;

                client
                    .app_secrets_store(project, name, secret.as_bytes())
                    .await?;
            }
        }

        Ok(())
    }
}