From 294ecfcd6e1bff9ddeee3b6b654b5324b7bdc6fe Mon Sep 17 00:00:00 2001 From: lucaspalomodevelop Date: Mon, 15 May 2023 18:39:47 +0200 Subject: [PATCH] add remove script --- src/main.cpp | 16 ++++++++++++++++ src/main.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 6b91095..4ac4882 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,7 +23,9 @@ void input(int argc, char *argv[]) command.addCommand("help", "- Shows this help message", help); command.addCommand("ls", "- Lists all scripts ", listScripts); command.addCommand("add", "[script] - Adds a script", addScript); + command.addCommand("new", "[script] - Adds a script", addScript); command.addCommand("edit", "[script] - Edits a script", editScript); + command.addCommand("remove", "[script] - Remove a script", removeScript); command.addDefaultCommand(runScript); command.runCommand(argv[1], argc, argv); } @@ -93,6 +95,20 @@ void editScript(std::string name) #endif } +void removeScript(int argc, char *argv[]) +{ + std::string script = dir + "/" + argv[1]; + if (std::filesystem::exists(script)) + { + std::cout << "Removing script: " << argv[1] << std::endl; + std::filesystem::remove(script); + } + else + { + std::cout << "Script " << argv[1] << " does not exist" << std::endl; + } +} + // help function for showing help message void help(int argc, char *argv[]) { diff --git a/src/main.h b/src/main.h index 232abb5..9c6f034 100644 --- a/src/main.h +++ b/src/main.h @@ -31,6 +31,8 @@ void addScript(int argc, char *argv[]); // edit a script in the autom directory void editScript(int argc, char *argv[]); void editScript(std::string name); +// remove a script in the autom directory +void removeScript(int argc, char *argv[]); // help function for showing help message void help(int argc, char *argv[]); // void create(int argc,char *argv[]);