bos-cli 0.3.4

Command line utility helps to develop widgets for near.social by allowing developers to use standard developer tools like their best code editor and standard tools for source code version control, and then deploy their widgets to SocialDB in one command.
use inquire::Text;
use strum::{EnumDiscriminants, EnumIter, EnumMessage};

mod account_id;
mod function_call_access_key;
mod sign_as;
mod storage_deposit;

#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
#[interactive_clap(input_context = near_cli_rs::GlobalContext)]
#[interactive_clap(output_context = SocialDbKeyContext)]
pub struct SocialDbKey {
    #[interactive_clap(skip_default_input_arg)]
    /// Enter the prefix of the social_db key that you will grant permission to (default value: 'widget'):
    social_db_key: String,
    #[interactive_clap(subcommand)]
    access: Access,
}

#[derive(Clone)]
pub struct SocialDbKeyContext {
    pub global_context: near_cli_rs::GlobalContext,
    pub social_db_key: String,
}

impl SocialDbKeyContext {
    pub fn from_previous_context(
        previous_context: near_cli_rs::GlobalContext,
        scope: &<SocialDbKey as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
    ) -> color_eyre::eyre::Result<Self> {
        Ok(Self {
            global_context: previous_context,
            social_db_key: scope.social_db_key.clone(),
        })
    }
}

impl SocialDbKey {
    fn input_social_db_key(
        _context: &near_cli_rs::GlobalContext,
    ) -> color_eyre::eyre::Result<Option<String>> {
        Ok(Some(
            Text::new("Enter the prefix of the social_db key that you will grant permission to (default value: 'widget'):")
                .with_default("widget")
                .prompt()?,
        ))
    }
}

#[derive(Debug, EnumDiscriminants, Clone, interactive_clap::InteractiveClap)]
#[interactive_clap(context = SocialDbKeyContext)]
#[strum_discriminants(derive(EnumMessage, EnumIter))]
/// Select grant access permissions:
pub enum Access {
    #[strum_discriminants(strum(
        message = "to-function-call-access-key  -   Granting access to a function-call-only access key"
    ))]
    /// Granting access to a function-call-only access key
    ToFunctionCallAccessKey(self::function_call_access_key::AccessToPublicKey),
    #[strum_discriminants(strum(
        message = "to-account                   -   Granting access to a different account"
    ))]
    /// Granting access to a different account
    ToAccount(self::account_id::AccessToAccount),
}