From 0f561feb3aa9698dd55ef54372b973c84b94610f Mon Sep 17 00:00:00 2001 From: Edoardo Marangoni Date: Mon, 17 Jun 2024 15:35:41 +0200 Subject: [PATCH 1/2] feat(cli/deploy): Add `--path` flag --- lib/cli/src/commands/app/create.rs | 1 + lib/cli/src/commands/app/deploy.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/cli/src/commands/app/create.rs b/lib/cli/src/commands/app/create.rs index addf5e4d4a2..dbaf1dd941c 100644 --- a/lib/cli/src/commands/app/create.rs +++ b/lib/cli/src/commands/app/create.rs @@ -625,6 +625,7 @@ the app:\n" non_interactive: self.non_interactive, publish_package: true, dir: self.app_dir_path.clone(), + path: None, no_wait: self.no_wait, no_default: false, no_persist_id: false, diff --git a/lib/cli/src/commands/app/deploy.rs b/lib/cli/src/commands/app/deploy.rs index 7cf55daff71..f5c28aa60fd 100644 --- a/lib/cli/src/commands/app/deploy.rs +++ b/lib/cli/src/commands/app/deploy.rs @@ -49,6 +49,10 @@ pub struct CmdAppDeploy { #[clap(long)] pub dir: Option, + /// The path to the `app.yaml` file. + #[clap(long, conflicts_with = "dir")] + pub path: Option, + /// Do not wait for the app to become reachable. #[clap(long)] pub no_wait: bool, @@ -226,7 +230,11 @@ impl AsyncCliCommand for CmdAppDeploy { let client = login_user(&self.api, &self.env, !self.non_interactive, "deploy an app").await?; - let base_dir_path = self.dir.clone().unwrap_or(std::env::current_dir()?); + let base_dir_path = self + .dir + .clone() + .unwrap_or(self.path.clone().unwrap_or(std::env::current_dir()?)); + let (app_config_path, base_dir_path) = { if base_dir_path.is_file() { ( @@ -508,7 +516,7 @@ impl AsyncCliCommand for CmdAppDeploy { // If the config changed, write it back. if new_app_config != app_config { // We want to preserve unknown fields to allow for newer app.yaml - // settings without requring new CLI versions, so instead of just + // settings without requiring new CLI versions, so instead of just // serializing the new config, we merge it with the old one. let new_merged = crate::utils::merge_yaml_values( &app_config.clone().to_yaml_value()?, From b0715e4833eb07582554f99c375fff29c7b73f46 Mon Sep 17 00:00:00 2001 From: Edoardo Marangoni Date: Tue, 18 Jun 2024 11:46:34 +0200 Subject: [PATCH 2/2] fix(cli/deploy): use `unwrap_or_else` --- lib/cli/src/commands/app/deploy.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/cli/src/commands/app/deploy.rs b/lib/cli/src/commands/app/deploy.rs index f5c28aa60fd..bcf80d5b42c 100644 --- a/lib/cli/src/commands/app/deploy.rs +++ b/lib/cli/src/commands/app/deploy.rs @@ -230,10 +230,11 @@ impl AsyncCliCommand for CmdAppDeploy { let client = login_user(&self.api, &self.env, !self.non_interactive, "deploy an app").await?; - let base_dir_path = self - .dir - .clone() - .unwrap_or(self.path.clone().unwrap_or(std::env::current_dir()?)); + let base_dir_path = self.dir.clone().unwrap_or_else(|| { + self.path + .clone() + .unwrap_or_else(|| std::env::current_dir().unwrap()) + }); let (app_config_path, base_dir_path) = { if base_dir_path.is_file() {