View command added.

This commit is contained in:
Your Name 2025-04-26 00:22:13 +12:00
parent 8e0683c997
commit 6251849923

View File

@ -30,6 +30,7 @@ void 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 << "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 << " install SERVER [SERVICE] Install/reinstall/update service(s). Non-destructive." << std::endl;
std::cout << " view [SERVER] [SERVICE] View 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 << " 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 << " COMMAND SERVER [SERVICE] Run a command on service(s)." << std::endl;
std::cout << std::endl; std::cout << std::endl;
@ -73,9 +74,7 @@ int main(int argc, char* argv[]) {
cfg->load_config(); cfg->load_config();
if (argc == 1) { if (argc == 1) {
dropshell::list_servers(); dropshell::print_help();
std::cout << std::endl;
std::cout << "dropshell help - get help on using dropshell" << std::endl;
return 0; return 0;
} }
std::string cmd = argv[1]; std::string cmd = argv[1];
@ -132,7 +131,8 @@ int main(int argc, char* argv[]) {
}); });
if (cfg->is_config_set()) if (cfg->is_config_set())
full_command_set.merge(std::set<std::string>{ full_command_set.merge(std::set<std::string>{
"server","templates","create-service","create-template","create-server","edit","ssh" // only if we have a config. "server","templates","create-service","create-template","create-server","edit","ssh",
"view" // only if we have a config.
}); });
for (const auto& command : full_command_set) { for (const auto& command : full_command_set) {
@ -196,15 +196,21 @@ int main(int argc, char* argv[]) {
return 0; return 0;
} }
if (cmd == "server") { if (cmd == "server" || cmd == "servers" || cmd == "view" || cmd == "views" || cmd == "v")
if (argc > 2) { switch (argc)
// Show details for specific server {
dropshell::show_server_details(argv[2]); case 2:
} else {
// List all servers
dropshell::list_servers(); dropshell::list_servers();
}
return 0; return 0;
case 3:
dropshell::show_server_details(argv[2]);
return 0;
case 4:
cmd="logs";
break;
default:
std::cerr << "dropshell server: too many arguments" << std::endl;
return 1;
} }
if (cmd == "templates") { if (cmd == "templates") {