.
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled

This commit is contained in:
Your Name 2025-05-17 17:22:23 +12:00
parent 4c0bca4def
commit 583bb18676
3 changed files with 13 additions and 5 deletions

View File

@ -33,7 +33,7 @@ namespace dropshell
false, // requires_install false, // requires_install
0, // min_args (after command) 0, // min_args (after command)
2, // max_args (after command) 2, // max_args (after command)
"install SERVER [SERVICE]", "install SERVER [SERVICE|all]",
"Install/reinstall service(s). Safe/non-destructive way to update.", "Install/reinstall service(s). Safe/non-destructive way to update.",
// heredoc // heredoc
R"( R"(
@ -42,7 +42,7 @@ namespace dropshell
install (re)install dropshell components on this computer. install (re)install dropshell components on this computer.
install SERVER (re)install dropshell agent on the given server. install SERVER (re)install dropshell agent on the given server.
install SERVER [SERVICE|*] (re)install the given service (or all services) on the given server. install SERVER [SERVICE|all] (re)install the given service (or all services) on the given server.
Note you need to create the service first with: Note you need to create the service first with:
dropshell create-service <server> <template> <service> dropshell create-service <server> <template> <service>
@ -360,6 +360,12 @@ namespace dropshell
return install_host(); return install_host();
} }
if (!gConfig().is_config_set())
{
std::cerr << "Error: Dropshell is not configured. Please run 'dropshell edit' to configure it." << std::endl;
return 1;
}
std::string server = safearg(ctx.args, 0); std::string server = safearg(ctx.args, 0);
if (ctx.args.size() == 1) if (ctx.args.size() == 1)
@ -368,9 +374,10 @@ namespace dropshell
} }
// install service(s) // install service(s)
if (safearg(ctx.args, 1) == "*") if (safearg(ctx.args, 1) == "all")
{ {
// install all services on the server // install all services on the server
maketitle("Installing all services on " + server);
bool okay = true; bool okay = true;
std::vector<LocalServiceInfo> services = get_server_services_info(server); std::vector<LocalServiceInfo> services = get_server_services_info(server);
for (const auto &service : services) for (const auto &service : services)

View File

@ -30,7 +30,7 @@ void std_autocomplete_allowstar(const CommandContext &ctx)
{ {
std_autocomplete(ctx); std_autocomplete(ctx);
if (ctx.args.size() == 1) if (ctx.args.size() == 1)
std::cout << "*" << std::endl; std::cout << "all" << std::endl;
} }
} // namespace dropshell } // namespace dropshell

View File

@ -69,8 +69,9 @@ int main(int argc, char* argv[]) {
int arg_count = ctx.args.size(); int arg_count = ctx.args.size();
if (arg_count < info->min_args || (info->max_args != -1 && arg_count > info->max_args)) { if (arg_count < info->min_args || (info->max_args != -1 && arg_count > info->max_args)) {
std::cerr << "Invalid number of arguments for command: " << ctx.command << std::endl; std::cerr << "Invalid number of arguments for command: " << ctx.command << std::endl;
std::cerr << "(" << ctx.args.size() << " args provided, " << ctx.command << " requires " << (info->min_args) << " to " << (info->max_args) << " args)" << std::endl;
std::cerr << "Usage: " << std::endl; std::cerr << "Usage: " << std::endl;
std::cout << " "; std::cerr << " ";
print_left_aligned(info->help_usage,30); print_left_aligned(info->help_usage,30);
std::cout << info->help_description << std::endl; std::cout << info->help_description << std::endl;
return 1; return 1;