dropshell release 2025.0521.2125
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
This commit is contained in:
63
source/src/commands/create-template.cpp
Normal file
63
source/src/commands/create-template.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include "command_registry.hpp"
|
||||
#include "config.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
#include "utils/directories.hpp"
|
||||
#include "shared_commands.hpp"
|
||||
#include "version.hpp"
|
||||
#include "utils/assert.hpp"
|
||||
#include "templates.hpp"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <filesystem>
|
||||
|
||||
namespace dropshell {
|
||||
|
||||
void create_template_autocomplete(const CommandContext& ctx);
|
||||
int create_template_handler(const CommandContext& ctx);
|
||||
|
||||
static std::vector<std::string> create_template_name_list={"create-template"};
|
||||
|
||||
// Static registration
|
||||
struct CreateTemplateCommandRegister {
|
||||
CreateTemplateCommandRegister() {
|
||||
CommandRegistry::instance().register_command({
|
||||
create_template_name_list,
|
||||
create_template_handler,
|
||||
create_template_autocomplete,
|
||||
false, // hidden
|
||||
true, // requires_config
|
||||
true, // requires_install
|
||||
1, // min_args (after command)
|
||||
1, // max_args (after command)
|
||||
"create-template TEMPLATE",
|
||||
"Create a new template.",
|
||||
// heredoc
|
||||
R"(
|
||||
Create a new template.
|
||||
|
||||
create-template TEMPLATE
|
||||
)"
|
||||
});
|
||||
}
|
||||
} create_template_command_register;
|
||||
|
||||
|
||||
void create_template_autocomplete(const CommandContext& ctx) {
|
||||
return; // can't autocomplete as it's a new server!
|
||||
}
|
||||
|
||||
|
||||
int create_template_handler(const CommandContext& ctx) {
|
||||
// create a new server entry on this host
|
||||
if (ctx.args.size() == 0) {
|
||||
error << "No template name provided" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
bool ok = gTemplateManager().create_template(ctx.args[0]);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace dropshell
|
Reference in New Issue
Block a user