generated from pure_sagacity/rust-starter
added the deletion of projects
This commit is contained in:
+60
-16
@@ -9,10 +9,11 @@ use colored::*;
|
||||
const GIT_VERSION: &str = env!("GIT_VERSION");
|
||||
|
||||
fn main() {
|
||||
use cli::{Commands, ConfigCommands, ProjectCommands};
|
||||
let cli = Cli::parse();
|
||||
|
||||
if cli.version {
|
||||
let top_msg = format!("Harbor version {}", crate_version!().green()).bright_blue();
|
||||
let top_msg = format!("Harbor version {}", crate_version!().green()).bright_cyan();
|
||||
let bottom_msg =
|
||||
format!("An open source secrets management and distribution platform.").blue();
|
||||
let commit_msg = format!("Git commit {}", GIT_VERSION).dimmed();
|
||||
@@ -23,24 +24,24 @@ fn main() {
|
||||
|
||||
match cli.command {
|
||||
Some(c) => match c {
|
||||
cli::Commands::Add {} => {
|
||||
Commands::Add {} => {
|
||||
println!("Add command executed");
|
||||
}
|
||||
cli::Commands::Config { command } => match command {
|
||||
cli::ConfigCommands::List {} => {
|
||||
Commands::Config { command } => match command {
|
||||
ConfigCommands::List {} => {
|
||||
println!("Config list command executed");
|
||||
}
|
||||
cli::ConfigCommands::Create { project } => {
|
||||
ConfigCommands::Create { project } => {
|
||||
println!("Config create command executed for project: {}", project);
|
||||
}
|
||||
cli::ConfigCommands::Delete { project, name } => {
|
||||
ConfigCommands::Delete { project, name } => {
|
||||
println!(
|
||||
"Config delete command executed for project: {}, name: {}",
|
||||
project, name
|
||||
);
|
||||
}
|
||||
},
|
||||
cli::Commands::Inject { verbose, after } => {
|
||||
Commands::Inject { verbose, after } => {
|
||||
println!(
|
||||
"Inject command executed with verbose: {}, after: {:?}",
|
||||
verbose, after
|
||||
@@ -48,14 +49,14 @@ fn main() {
|
||||
// for harbor inject -- bun dev
|
||||
// after = ["bun", "dev"]
|
||||
}
|
||||
cli::Commands::List {} => {
|
||||
Commands::List {} => {
|
||||
println!("List command executed");
|
||||
}
|
||||
cli::Commands::Project { command } => match command {
|
||||
cli::ProjectCommands::List {} => {
|
||||
Commands::Project { command } => match command {
|
||||
ProjectCommands::List {} => {
|
||||
println!("Project list command executed");
|
||||
}
|
||||
cli::ProjectCommands::Create {} => {
|
||||
ProjectCommands::Create {} => {
|
||||
let project_name = match get_input("Project name", ':', false) {
|
||||
Ok(name) => name,
|
||||
Err(e) => {
|
||||
@@ -65,21 +66,64 @@ fn main() {
|
||||
};
|
||||
|
||||
match cli::interactions::create_project(&project_name) {
|
||||
Ok(()) => println!("{}", "Project created successfully".blue()),
|
||||
Ok(()) => println!("{}", "Project created successfully.".cyan()),
|
||||
Err(e) => {
|
||||
eprintln!("Error creating project: {}", e);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
cli::ProjectCommands::Delete { name } => {
|
||||
println!("Project delete command executed for name: {}", name);
|
||||
ProjectCommands::Delete { name } => {
|
||||
// We'll check if the project exists before prompting for confirmation
|
||||
let exists = match cli::interactions::project_exists(&name) {
|
||||
Ok(exists) => exists,
|
||||
Err(e) => {
|
||||
eprintln!("Error checking if project exists: {}", e);
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
if !exists {
|
||||
eprintln!("Project '{}' does not exist.", name);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
// Prompt for confirmation
|
||||
let confirmation = match get_input(
|
||||
format!(
|
||||
"Are you sure you want to delete the project '{}'? (y/N)",
|
||||
name
|
||||
)
|
||||
.red(),
|
||||
':',
|
||||
false,
|
||||
) {
|
||||
Ok(input) => input,
|
||||
Err(e) => {
|
||||
eprintln!("Error getting confirmation: {}", e);
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
if confirmation.to_lowercase() == "y" {
|
||||
match cli::interactions::delete_project(&name) {
|
||||
Ok(()) => {
|
||||
println!("{}", "Project deleted successfully.".cyan())
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Error deleting project: {}", e);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println!("Project deletion canceled.");
|
||||
}
|
||||
}
|
||||
},
|
||||
cli::Commands::Shell {} => {
|
||||
Commands::Shell {} => {
|
||||
println!("Shell command executed");
|
||||
}
|
||||
cli::Commands::Setup {} => {
|
||||
Commands::Setup {} => {
|
||||
println!("Setup command executed");
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user