This commit is contained in:
63
source/src/commands/create-server.cpp
Normal file
63
source/src/commands/create-server.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 <unistd.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <filesystem>
|
||||
#include "utils/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
|
||||
false, // requires_config
|
||||
false, // requires_install
|
||||
0, // 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
|
@ -14,7 +14,7 @@ namespace dropshell
|
||||
{
|
||||
|
||||
int nuke_handler(const CommandContext &ctx);
|
||||
static std::vector<std::string> nuke_name_list = {"nuke"};
|
||||
static std::vector<std::string> nuke_name_list = {"destroy","nuke"};
|
||||
|
||||
// Static registration
|
||||
struct NukeCommandRegister
|
||||
@ -29,15 +29,15 @@ namespace dropshell
|
||||
true, // requires_install
|
||||
2, // min_args (after command)
|
||||
2, // max_args (after command)
|
||||
"nuke SERVER SERVICE|all",
|
||||
"Nuke a service on a server. Destroys everything, both local and remote!",
|
||||
"destroy SERVER SERVICE|all",
|
||||
"Destroy a service on a server. Erases everything, both local and remote!",
|
||||
// heredoc
|
||||
R"(
|
||||
Nuke a service.
|
||||
|
||||
Examples:
|
||||
nuke SERVER SERVICE nuke the given service on the given server.
|
||||
nuke SERVER all nuke all services on the given server.
|
||||
destroy SERVER SERVICE destroy the given service on the given server.
|
||||
destroy SERVER all destroy all services on the given server.
|
||||
|
||||
Note: This command is destructive and will destroy all data and all configuration,
|
||||
both on the dropshell host and on the remote server.
|
@ -148,6 +148,7 @@ int help_handler(const CommandContext& ctx) {
|
||||
info << std::endl;
|
||||
show_command("ssh");
|
||||
info << std::endl;
|
||||
show_command("create-server");
|
||||
show_command("create-service");
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user