feat: add list servers command
This commit is contained in:
@@ -20,6 +20,7 @@ cargo install --path .
|
||||
|
||||
```sh
|
||||
xboctploy --list # показать проекты из конфига
|
||||
xboctploy --list-servers # показать серверы из конфига
|
||||
xboctploy --dry-run demo # напечатать план деплоя без выполнения
|
||||
xboctploy demo # задеплоить проект demo
|
||||
```
|
||||
|
||||
+5
-1
@@ -5,7 +5,8 @@ use clap::{ArgGroup, Parser};
|
||||
/// Deploy hobby projects from a local PC to a VPS over SSH.
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(name = "xboctploy", version, about)]
|
||||
#[command(group = ArgGroup::new("target").required(true).args(["project", "list"]))]
|
||||
#[command(arg_required_else_help = true)]
|
||||
#[command(group = ArgGroup::new("target").required(true).args(["project", "list", "list_servers"]))]
|
||||
pub struct Cli {
|
||||
/// Project name from deploy.toml
|
||||
pub project: Option<String>,
|
||||
@@ -18,4 +19,7 @@ pub struct Cli {
|
||||
/// List configured projects and exit
|
||||
#[arg(long)]
|
||||
pub list: bool,
|
||||
/// List configured servers and exit
|
||||
#[arg(long)]
|
||||
pub list_servers: bool,
|
||||
}
|
||||
|
||||
+16
@@ -31,6 +31,22 @@ fn run(cli: &cli::Cli) -> Result<()> {
|
||||
let path = config::resolve(cli.config.as_deref())?;
|
||||
let cfg = config::load(&path)?;
|
||||
|
||||
if cli.list_servers {
|
||||
println!("config: {}", path.display());
|
||||
println!("configured servers:");
|
||||
for (name, server) in &cfg.servers {
|
||||
let mut line = format!(" - {name} {}", server.host);
|
||||
if let Some(port) = server.port {
|
||||
line.push_str(&format!(":{port}"));
|
||||
}
|
||||
if let Some(user) = &server.user {
|
||||
line.push_str(&format!(" as {user}"));
|
||||
}
|
||||
println!("{line}");
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if cli.list {
|
||||
println!("config: {}", path.display());
|
||||
println!("configured projects:");
|
||||
|
||||
Reference in New Issue
Block a user