:-'Generic Commit'

This commit is contained in:
Your Name 2025-05-28 21:03:40 +12:00
parent f5c585c67d
commit 401280cf23

View File

@ -243,6 +243,45 @@ int update_tool(int argc, char* argv[]) {
return install_tool(3, fakeArgv); return install_tool(3, fakeArgv);
} }
int create_tool(int argc, char* argv[]) {
if (argc < 3) {
std::cerr << "Usage: dropshell-tool create <tool_name>" << 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 } // end anonymous namespace
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
@ -269,7 +308,7 @@ help
} else if (command == "version") { } else if (command == "version") {
std::cout << dropshell::VERSION << std::endl; std::cout << dropshell::VERSION << std::endl;
} else if (command == "create") { } else if (command == "create") {
// TODO: Implement create logic return create_tool(argc, argv);
} else if (command == "help") { } else if (command == "help") {
std::cout << "Usage: dropshell-tool <command> [args...]" << std::endl; std::cout << "Usage: dropshell-tool <command> [args...]" << std::endl;
std::cout << "Commands:" << std::endl; std::cout << "Commands:" << std::endl;