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 committed Jun 19, 2024
2 parents d87a0bc + 1efff7f commit 430399a
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
49 changes: 47 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["cli", "slot"]

[workspace.package]
version = "0.7.5"
version = "0.7.6"
license-file = "LICENSE"
repository = "https://github.com/cartridge-gg/slot/"
edition = "2021"
Expand Down
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 430399a

Please sign in to comment.