feat: update app with new commands flow
This commit is contained in:
+39
-19
@@ -1,32 +1,52 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::{ArgGroup, Parser};
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
|
||||
/// Deploy hobby projects from a local PC to a VPS over SSH.
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(name = "xboct-deploy", version, about)]
|
||||
#[command(arg_required_else_help = true)]
|
||||
#[command(group = ArgGroup::new("target").required(true).args(["project", "list", "list_servers", "pick", "this"]))]
|
||||
pub struct Cli {
|
||||
/// Project name from deploy.toml
|
||||
#[arg(short, long)]
|
||||
pub project: Option<String>,
|
||||
// Global flags
|
||||
/// Use global config only
|
||||
#[arg(short, long, global = true)]
|
||||
pub global: bool,
|
||||
|
||||
/// Explicit path to the config file
|
||||
#[arg(long, value_name = "PATH")]
|
||||
#[arg(
|
||||
short,
|
||||
long,
|
||||
value_name = "PATH",
|
||||
global = true,
|
||||
conflicts_with = "global"
|
||||
)]
|
||||
pub config: Option<PathBuf>,
|
||||
|
||||
/// Print planned steps without executing anything
|
||||
#[arg(long)]
|
||||
pub dry_run: bool,
|
||||
/// List configured projects and exit
|
||||
#[arg(short, long)]
|
||||
pub list: bool,
|
||||
/// List configured servers and exit
|
||||
#[arg(long)]
|
||||
pub list_servers: bool,
|
||||
/// Interactively pick a project to deploy (fuzzy search)
|
||||
#[arg(short, long)]
|
||||
pub pick: bool,
|
||||
/// Deploy the project whose workdir matches the current folder (global config)
|
||||
#[arg(short, long)]
|
||||
pub this: bool,
|
||||
|
||||
#[command(subcommand)]
|
||||
pub command: Option<Commands>,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub enum Commands {
|
||||
/// Run deploy
|
||||
Deploy(DeployArgs),
|
||||
|
||||
/// Interactive select project to deploy
|
||||
Pick,
|
||||
|
||||
/// List all available projects
|
||||
List,
|
||||
|
||||
/// List all available servers
|
||||
ListServers,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub struct DeployArgs {
|
||||
/// Name of the project to deploy
|
||||
#[arg(value_name = "PROJECT_NAME")]
|
||||
pub project_name: Option<String>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user