Skip to content

Commit

Permalink
Merge pull request #63 from notV4l/confirm_delete
Browse files Browse the repository at this point in the history
add confirmation for slot d delete
  • Loading branch information
tarrencev authored Jun 18, 2024
2 parents d87a0bc + 1efff7f commit 466f16b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ anyhow.workspace = true
axum.workspace = true
clap = { version = "4.2", features = ["derive"] }
ctrlc = "3.4.1"
dialoguer = "0.11.0"
env_logger = "0.10"
log = "0.4"
graphql_client.workspace = true
Expand Down
22 changes: 22 additions & 0 deletions cli/src/command/deployments/delete.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use anyhow::Result;
use clap::Args;
use dialoguer::theme::ColorfulTheme;
use dialoguer::Confirm;
use slot::graphql::deployments::{delete_deployment::*, DeleteDeployment};
use slot::graphql::{GraphQLQuery, Response};
use slot::{api::Client, credential::Credentials};
Expand All @@ -19,10 +21,30 @@ pub struct DeleteArgs {

#[arg(help = "The name of the service.")]
pub service: Service,

#[arg(help = "Force delete without confirmation", short('f'))]
pub force: bool,
}

impl DeleteArgs {
pub async fn run(&self) -> Result<()> {
if !self.force {
let confirmation = Confirm::with_theme(&ColorfulTheme::default())
.with_prompt(format!(
"Please confirm to delete {} {:?}",
&self.project, &self.service
))
.default(false)
.show_default(true)
.wait_for_newline(true)
.interact()
.unwrap();

if !confirmation {
return Ok(());
}
}

let service = match &self.service {
Service::Katana => DeploymentService::katana,
Service::Torii => DeploymentService::torii,
Expand Down

0 comments on commit 466f16b

Please sign in to comment.