Skip to content

Commit

Permalink
ask for confirmation of file delete
Browse files Browse the repository at this point in the history
  • Loading branch information
tippenein authored and hugocaillard committed Dec 6, 2023
1 parent 7097784 commit f8f02c6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion components/clarinet-cli/src/frontend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ pub fn main() {
}
Contracts::RemoveContract(cmd) => {
let manifest = load_manifest_or_exit(cmd.manifest_path);

let contract_name = cmd.name.clone();
let changes =
match generate::get_changes_for_rm_contract(&manifest.location, cmd.name) {
Ok(changes) => changes,
Expand All @@ -941,6 +941,18 @@ pub fn main() {
}
};

let mut answer = String::new();
println!(
"{} This command will delete the files {}.test.ts, {}.clar, and remove the contract from the manifest. Do you confirm? [y/N]",
yellow!("warning:"),
&contract_name,
&contract_name
);
std::io::stdin().read_line(&mut answer).unwrap();
if !answer.trim().eq_ignore_ascii_case("y") {
println!("{} Not deleting contract files", yellow!("warning:"));
std::process::exit(0);
}
if !execute_changes(changes) {
std::process::exit(1);
}
Expand Down

0 comments on commit f8f02c6

Please sign in to comment.