diff --git a/src/bin/spin.rs b/src/bin/spin.rs index 97e5f7535..419602d48 100644 --- a/src/bin/spin.rs +++ b/src/bin/spin.rs @@ -5,6 +5,7 @@ use lazy_static::lazy_static; use spin_cli::commands::{ bindle::BindleCommands, build::BuildCommand, + cloud::CloudCommands, deploy::DeployCommand, external::execute_external_subcommand, login::LoginCommand, @@ -52,11 +53,17 @@ enum SpinApp { Up(UpCommand), #[clap(subcommand)] Bindle(BindleCommands), + #[clap(subcommand)] + Cloud(CloudCommands), + // hidden to "work" as a cross-level subcommand alias -> `spin cloud deploy` + #[clap(hide = true)] + Deploy(DeployCommand), + // hidden to "work" as a cross-level subcommand alias -> `spin cloud login` + #[clap(hide = true)] + Login(LoginCommand), #[clap(subcommand, alias = "oci")] Registry(RegistryCommands), - Deploy(DeployCommand), Build(BuildCommand), - Login(LoginCommand), #[clap(subcommand, alias = "plugin")] Plugins(PluginCommands), #[clap(subcommand, hide = true)] @@ -82,13 +89,14 @@ impl SpinApp { Self::New(cmd) => cmd.run().await, Self::Add(cmd) => cmd.run().await, Self::Bindle(cmd) => cmd.run().await, - Self::Registry(cmd) => cmd.run().await, + Self::Cloud(cmd) => cmd.run().await, Self::Deploy(cmd) => cmd.run().await, + Self::Login(cmd) => cmd.run().await, + Self::Registry(cmd) => cmd.run().await, Self::Build(cmd) => cmd.run().await, Self::Trigger(TriggerCommands::Http(cmd)) => cmd.run().await, Self::Trigger(TriggerCommands::Redis(cmd)) => cmd.run().await, Self::Trigger(TriggerCommands::HelpArgsOnly(cmd)) => cmd.run().await, - Self::Login(cmd) => cmd.run().await, Self::Plugins(cmd) => cmd.run().await, Self::External(cmd) => execute_external_subcommand(cmd, SpinApp::command()).await, } diff --git a/src/commands.rs b/src/commands.rs index 6a7fd6869..fbb0be126 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -4,11 +4,13 @@ pub mod bindle; /// Commands for building Spin applications. pub mod build; -/// Command for deploying a Spin app to Hippo +/// Commands for publishing applications to the Fermyon Platform. +pub mod cloud; +/// Command to package and upload an application to the Fermyon Platform. pub mod deploy; /// Commands for external subcommands (i.e. plugins) pub mod external; -// Command for logging into the server +/// Command for logging into the Fermyon Platform. pub mod login; /// Command for creating a new application. pub mod new; diff --git a/src/commands/cloud.rs b/src/commands/cloud.rs new file mode 100644 index 000000000..280fe173c --- /dev/null +++ b/src/commands/cloud.rs @@ -0,0 +1,24 @@ +use anyhow::Result; +use clap::Subcommand; + +use super::deploy::DeployCommand; +use super::login::LoginCommand; + +/// Commands for publishing applications to the Fermyon Platform. +#[derive(Subcommand, Debug)] +pub enum CloudCommands { + /// Package and upload an application to the Fermyon Platform. + Deploy(DeployCommand), + + /// Log into the Fermyon Platform. + Login(LoginCommand), +} + +impl CloudCommands { + pub async fn run(self) -> Result<()> { + match self { + Self::Deploy(cmd) => cmd.run().await, + Self::Login(cmd) => cmd.run().await, + } + } +} diff --git a/src/commands/deploy.rs b/src/commands/deploy.rs index a885f0952..e0b702dcc 100644 --- a/src/commands/deploy.rs +++ b/src/commands/deploy.rs @@ -38,9 +38,9 @@ const SPIN_DEPLOY_CHANNEL_NAME: &str = "spin-deploy"; const BINDLE_REGISTRY_URL_PATH: &str = "api/registry"; -/// Package and upload Spin artifacts, notifying Hippo +/// Package and upload an application to the Fermyon Platform. #[derive(Parser, Debug)] -#[clap(about = "Deploy a Spin application")] +#[clap(about = "Package and upload an application to the Fermyon Platform")] pub struct DeployCommand { /// Path to spin.toml #[clap( diff --git a/src/commands/login.rs b/src/commands/login.rs index 847c3f636..0797709af 100644 --- a/src/commands/login.rs +++ b/src/commands/login.rs @@ -28,9 +28,9 @@ const SPIN_CLIENT_ID: &str = "583e63e9-461f-4fbe-a246-23e0fb1cad10"; const DEFAULT_CLOUD_URL: &str = "https://cloud.fermyon.com/"; -/// Log into the server +/// Log into the Fermyon Platform. #[derive(Parser, Debug)] -#[clap(about = "Log into the server")] +#[clap(about = "Log into the Fermyon Platform")] pub struct LoginCommand { /// URL of bindle server #[clap(