diff --git a/src/main.cpp b/src/main.cpp index 5c1711e..03c53f3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,14 +40,17 @@ bool print_help() { std::cout << std::endl; std::cout << std::endl; std::cout << "Service commands: (if no service is specified, all services for the server are affected)" << std::endl; - std::cout << " install SERVER [SERVICE] Install/reinstall/update service(s). Non-destructive." << std::endl; std::cout << " list [SERVER] [SERVICE] List status/details of all servers/server/service." << std::endl; std::cout << " edit [SERVER] [SERVICE] Edit the configuration of dropshell/server/service." << std::endl; - std::cout << " COMMAND SERVER [SERVICE] Run a command on service(s)." << std::endl; std::cout << std::endl; - std::cout << "Standard commands: install, uninstall, backup, restore, start, stop" << std::endl; + std::cout << " install SERVER [SERVICE] Install/reinstall/update service(s). Safe/non-destructive." << std::endl; + std::cout << " uninstall SERVER [SERVICE] Uninstalls the service on the remote server. Leaves data intact." << std::endl; + std::cout << " nuke SERVER SERVICE Nuke the service on the remote server, deleting all remote data." << std::endl; std::cout << std::endl; - std::cout << " ssh SERVER [SERVICE] Launch an interactive shell on a server or service" << std::endl; + std::cout << " COMMAND SERVER [SERVICE] Run a command on service(s), e.g." << std::endl; + std::cout << " backup, restore, start, stop, logs" << std::endl; + std::cout << std::endl; + std::cout << " ssh SERVER SERVICE Launch an interactive shell on a server or service" << std::endl; std::cout << std::endl; std::cout << "Creation commands: (apply to the first local config directory)"< argvec; - for (int i=0; i argvec; + for (int i=0; i commands; get_all_used_commands(commands); commands.merge(std::set{"ssh","edit","_allservicesstatus"}); // handled by service_runner, but not in template_shell_commands. - for (const auto& command : commands) { - if (cmd == command) { - ServerAndServices server_and_services; - if (!getCLIServices(safearg(argc, argv, 2), safearg(argc, argv, 3), server_and_services)) { - std::cerr << "Error: " << command << " command requires server name and optionally service name" << std::endl; - return 1; - } - for (const auto& service_info : server_and_services.servicelist) { - service_runner runner(server_and_services.server_name, service_info.service_name); - if (!runner.isValid()) { - std::cerr << "Error: Failed to initialize service" << std::endl; - return 1; - } - std::vector additional_args; - for (int i=4; i safe_commands = {"nuke", "fullnuke"}; + if (safe_commands.count(cmd) && argc < 4) + return die("Error: "+cmd+" requires a server name and service name. For safety, can't run on all services."); + + // get all the services to run the command on. + ServerAndServices server_and_services; + if (!getCLIServices(safearg(argc, argv, 2), safearg(argc, argv, 3), server_and_services)) + return die("Error: "+cmd+" command requires server name and optionally service name"); + + // run the command on each service. + for (const auto& service_info : server_and_services.servicelist) { + service_runner runner(server_and_services.server_name, service_info.service_name); + if (!runner.isValid()) + return die("Error: Failed to initialize service"); + + std::vector additional_args; + for (int i=4; i