From 401280cf23f611999ce619ff40b792dec7ce76b1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 28 May 2025 21:03:40 +1200 Subject: [PATCH] :-'Generic Commit' --- dropshell-tool/src/main.cpp | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/dropshell-tool/src/main.cpp b/dropshell-tool/src/main.cpp index d300796..351b6e3 100644 --- a/dropshell-tool/src/main.cpp +++ b/dropshell-tool/src/main.cpp @@ -243,6 +243,45 @@ int update_tool(int argc, char* argv[]) { return install_tool(3, fakeArgv); } +int create_tool(int argc, char* argv[]) { + if (argc < 3) { + std::cerr << "Usage: dropshell-tool create " << std::endl; + return 1; + } + std::string toolName = argv[2]; + std::filesystem::path toolDir = std::filesystem::current_path() / toolName; + if (!std::filesystem::exists(toolDir)) { + std::filesystem::create_directories(toolDir); + std::cout << "Created directory: " << toolDir << std::endl; + } else { + std::cout << "Directory already exists: " << toolDir << std::endl; + } + std::filesystem::path configPath = toolDir / "dropshell-tool-config.json"; + if (!std::filesystem::exists(configPath)) { + nlohmann::json config = { + {"aliases", nlohmann::json::array()}, + {"setup_script", "setup_script.sh"} + }; + std::ofstream configFile(configPath); + configFile << config.dump(2); + configFile.close(); + std::cout << "Created config: " << configPath << std::endl; + } else { + std::cout << "Config already exists: " << configPath << std::endl; + } + std::filesystem::path setupScriptPath = toolDir / "setup_script.sh"; + if (!std::filesystem::exists(setupScriptPath)) { + std::ofstream setupFile(setupScriptPath); + setupFile << "#!/bin/bash\necho 'Setup complete.'\n"; + setupFile.close(); + std::filesystem::permissions(setupScriptPath, std::filesystem::perms::owner_exec | std::filesystem::perms::owner_write | std::filesystem::perms::owner_read); + std::cout << "Created setup script: " << setupScriptPath << std::endl; + } else { + std::cout << "Setup script already exists: " << setupScriptPath << std::endl; + } + return 0; +} + } // end anonymous namespace int main(int argc, char* argv[]) { @@ -269,7 +308,7 @@ help } else if (command == "version") { std::cout << dropshell::VERSION << std::endl; } else if (command == "create") { - // TODO: Implement create logic + return create_tool(argc, argv); } else if (command == "help") { std::cout << "Usage: dropshell-tool [args...]" << std::endl; std::cout << "Commands:" << std::endl;