Update source/src/commands/create-service.cpp
This commit is contained in:
@@ -30,14 +30,15 @@ namespace dropshell
|
|||||||
false, // hidden
|
false, // hidden
|
||||||
true, // requires_config
|
true, // requires_config
|
||||||
true, // requires_install
|
true, // requires_install
|
||||||
3, // min_args (after command)
|
2, // min_args (after command)
|
||||||
3, // max_args (after command)
|
3, // max_args (after command)
|
||||||
"create-service SERVER SERVICE TEMPLATE",
|
"create-service SERVER TEMPLATE [SERVICE]",
|
||||||
"Create a service on a server.",
|
"Create a service on a server.",
|
||||||
// heredoc
|
// heredoc
|
||||||
R"(
|
R"(
|
||||||
Create a service on a server.
|
Create a service on a server.
|
||||||
create-service SERVER SERVICE TEMPLATE create the given service on the given server.
|
create-service SERVER TEMPLATE [SERVICE] create a service on the given server.
|
||||||
|
SERVICE defaults to TEMPLATE name if not specified.
|
||||||
)"});
|
)"});
|
||||||
}
|
}
|
||||||
} create_service_command_register;
|
} create_service_command_register;
|
||||||
@@ -45,24 +46,34 @@ namespace dropshell
|
|||||||
int create_service_handler(const CommandContext &ctx)
|
int create_service_handler(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
std::string server = safearg(ctx.args, 0);
|
std::string server = safearg(ctx.args, 0);
|
||||||
std::string service = safearg(ctx.args, 1);
|
std::string template_name = safearg(ctx.args, 1);
|
||||||
std::string template_name = safearg(ctx.args, 2);
|
std::string service = safearg(ctx.args, 2);
|
||||||
|
|
||||||
|
// Default service name to template name if not specified
|
||||||
|
if (service.empty())
|
||||||
|
service = template_name;
|
||||||
|
|
||||||
return shared_commands::create_service(server, template_name, service) ? 0 : 1;
|
return shared_commands::create_service(server, template_name, service) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_service_autocomplete(const CommandContext &ctx)
|
void create_service_autocomplete(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
if (ctx.args.size() < 2)
|
if (ctx.args.size() == 0)
|
||||||
shared_commands::std_autocomplete(ctx);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (ctx.args.size() == 2)
|
// First arg: server name
|
||||||
{
|
shared_commands::std_autocomplete(ctx);
|
||||||
std::set<std::string> templates = gTemplateManager().get_template_list();
|
}
|
||||||
for (const auto &template_name : templates)
|
else if (ctx.args.size() == 1)
|
||||||
rawout << template_name << std::endl;
|
{
|
||||||
}
|
// Second arg: template name
|
||||||
|
std::set<std::string> templates = gTemplateManager().get_template_list();
|
||||||
|
for (const auto &template_name : templates)
|
||||||
|
rawout << template_name << std::endl;
|
||||||
|
}
|
||||||
|
else if (ctx.args.size() == 2)
|
||||||
|
{
|
||||||
|
// Third arg: service name - suggest template name as default
|
||||||
|
rawout << ctx.args[1] << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user