smbcloud_cli/cli/
mod.rs

1use crate::{account, project};
2use clap::{Parser, Subcommand};
3use smbcloud_networking::environment::Environment;
4use spinners::Spinner;
5
6pub struct CommandResult {
7    pub spinner: Spinner,
8    pub symbol: String,
9    pub msg: String,
10}
11
12impl CommandResult {
13    pub fn stop_and_persist(mut self) {
14        self.spinner.stop_and_persist(&self.symbol, self.msg);
15    }
16}
17
18#[derive(Parser)]
19#[clap(author, version, about)]
20pub struct Cli {
21    /// Environment: dev, production
22    #[arg(short, long, env = "ENVIRONMENT", default_value = "production")]
23    pub environment: Environment,
24
25    /// Log level: trace, debug, info, warn, error, off
26    #[clap(short, long, global = true)]
27    pub log_level: Option<String>,
28
29    #[command(subcommand)]
30    pub command: Option<Commands>,
31}
32
33#[derive(Subcommand)]
34pub enum Commands {
35    #[clap(
36        about = "Deploy project. This is smb main command. Requires an smbCloud account.",
37        display_order = 0
38    )]
39    Deploy {},
40    #[clap(
41        about = "Initialize project. Requires an smbCloud account.",
42        display_order = 1
43    )]
44    Init {},
45    #[clap(about = "Login to your account.", display_order = 2)]
46    Login {},
47    #[clap(about = "Logout from your account.", display_order = 3)]
48    Logout {},
49    #[clap(about = "Manage your account.")]
50    Account {
51        #[clap(subcommand)]
52        command: account::cli::Commands,
53    },
54    #[clap(about = "Manage your projects.")]
55    Project {
56        #[clap(subcommand)]
57        command: project::cli::Commands,
58    },
59}