feat: add deploy from current work directory command
This commit is contained in:
+22
-2
@@ -28,11 +28,15 @@ fn main() -> ExitCode {
|
||||
}
|
||||
|
||||
fn run(cli: &cli::Cli) -> Result<()> {
|
||||
if cli.this {
|
||||
return deploy_this(cli.dry_run);
|
||||
}
|
||||
|
||||
let path = config::resolve(cli.config.as_deref())?;
|
||||
let cfg = config::load(&path)?;
|
||||
|
||||
if cli.list_servers {
|
||||
println!("config: {}", path.display());
|
||||
println!("config: {}", config::display(&path));
|
||||
println!("configured servers:");
|
||||
for (name, server) in &cfg.servers {
|
||||
let mut line = format!(" - {name} {}", server.host);
|
||||
@@ -48,7 +52,7 @@ fn run(cli: &cli::Cli) -> Result<()> {
|
||||
}
|
||||
|
||||
if cli.list {
|
||||
println!("config: {}", path.display());
|
||||
println!("config: {}", config::display(&path));
|
||||
println!("configured projects:");
|
||||
for name in cfg.projects.keys() {
|
||||
println!(" - {name}");
|
||||
@@ -74,6 +78,22 @@ fn run(cli: &cli::Cli) -> Result<()> {
|
||||
deploy::deploy(&name, project, cli.dry_run)
|
||||
}
|
||||
|
||||
fn deploy_this(dry_run: bool) -> Result<()> {
|
||||
let path = config::resolve(None)?;
|
||||
let cfg = config::load(&path)?;
|
||||
|
||||
let cwd = std::env::current_dir().context("cannot determine current directory")?;
|
||||
let Some(name) = config::find_by_cwd(&cfg, &cwd) else {
|
||||
bail!(
|
||||
"no project in {} has workdir matching {}",
|
||||
config::display(&path),
|
||||
cwd.display()
|
||||
);
|
||||
};
|
||||
println!("config: {}", config::display(&path));
|
||||
deploy::deploy(name, &cfg.projects[name], dry_run)
|
||||
}
|
||||
|
||||
fn pick_project(cfg: &config::Config) -> Result<Option<String>> {
|
||||
use dialoguer::FuzzySelect;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user