smbcloud_cli/cli/
mod.rs

1use crate::{account, project};
2use clap::{Parser, Subcommand};
3use smbcloud_network::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(about = "Your account info.", display_order = 3)]
36    Me {},
37    #[clap(
38        about = "Deploy project. This is smb main command. Requires an smbCloud account.",
39        display_order = 0
40    )]
41    Deploy {},
42    #[clap(
43        about = "Initialize project. Requires an smbCloud account.",
44        display_order = 1
45    )]
46    Init {},
47    #[clap(about = "Login to your account.", display_order = 2)]
48    Login {},
49    #[clap(about = "Logout from your account.", display_order = 3)]
50    Logout {},
51    #[clap(about = "Manage your account.")]
52    Account {
53        #[clap(subcommand)]
54        command: account::cli::Commands,
55    },
56    #[clap(about = "Manage your projects.")]
57    Project {
58        #[clap(subcommand)]
59        command: project::cli::Commands,
60    },
61}