63 lines
1.7 KiB
C++
63 lines
1.7 KiB
C++
#include "command_registry.hpp"
|
|
#include "config.hpp"
|
|
#include "utils/utils.hpp"
|
|
#include "utils/directories.hpp"
|
|
#include "shared_commands.hpp"
|
|
#include "version.hpp"
|
|
|
|
#include <unistd.h>
|
|
#include <cstring>
|
|
#include <iostream>
|
|
#include <sstream>
|
|
#include <filesystem>
|
|
#include <libassert/assert.hpp>
|
|
|
|
namespace dropshell {
|
|
|
|
void create_server_autocomplete(const CommandContext& ctx);
|
|
int create_server_handler(const CommandContext& ctx);
|
|
|
|
static std::vector<std::string> create_server_name_list={"create-server"};
|
|
|
|
// Static registration
|
|
struct CreateServerCommandRegister {
|
|
CreateServerCommandRegister() {
|
|
CommandRegistry::instance().register_command({
|
|
create_server_name_list,
|
|
create_server_handler,
|
|
create_server_autocomplete,
|
|
false, // hidden
|
|
true, // requires_config
|
|
true, // requires_install
|
|
1, // min_args (after command)
|
|
1, // max_args (after command)
|
|
"create-server [SERVER]",
|
|
"Create a new server entry on this host.",
|
|
// heredoc
|
|
R"(
|
|
Create a new server entry on this host.
|
|
Note you will need to use ds install SERVER to prepare the service for use.
|
|
|
|
create-server SERVER
|
|
)"
|
|
});
|
|
}
|
|
} create_server_command_register;
|
|
|
|
|
|
void create_server_autocomplete(const CommandContext& ctx) {
|
|
return; // can't autocomplete as it's a new server!
|
|
}
|
|
|
|
|
|
int create_server_handler(const CommandContext& ctx) {
|
|
// create a new server entry on this host
|
|
if (ctx.args.size() == 0) {
|
|
error << "No server name provided" << std::endl;
|
|
return 1;
|
|
}
|
|
bool ok = create_server(ctx.args[0]);
|
|
return ok ? 0 : 1;
|
|
}
|
|
|
|
} // namespace dropshell
|