This commit is contained in:
64
src/commands/health.cpp
Normal file
64
src/commands/health.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "command_registry.hpp"
|
||||
#include "config.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
#include "service_runner.hpp"
|
||||
#include "utils/directories.hpp"
|
||||
#include "standard_autocomplete.hpp"
|
||||
#include "templates.hpp"
|
||||
#include "shared_commands.hpp"
|
||||
|
||||
|
||||
namespace dropshell {
|
||||
|
||||
int health_handler(const CommandContext& ctx);
|
||||
void health_autocomplete(const CommandContext& ctx);
|
||||
|
||||
static std::vector<std::string> health_name_list={"health","check","healthcheck","status"};
|
||||
|
||||
// Static registration
|
||||
struct HealthCommandRegister {
|
||||
HealthCommandRegister() {
|
||||
CommandRegistry::instance().register_command({
|
||||
health_name_list,
|
||||
health_handler,
|
||||
health_autocomplete,
|
||||
false, // hidden
|
||||
false, // requires_config
|
||||
1, // min_args (after command)
|
||||
2, // max_args (after command)
|
||||
"health SERVER",
|
||||
"Check the health of a server.",
|
||||
R"(
|
||||
health <server>
|
||||
)"
|
||||
});
|
||||
}
|
||||
} health_command_register;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// health command implementation
|
||||
|
||||
std::string healthtick(const std::string& server, const std::string& service) {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// health command implementation
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
int health_handler(const CommandContext& ctx) {
|
||||
if (ctx.args.size() < 1) {
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// health autocomplete
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void health_autocomplete(const CommandContext& ctx) {
|
||||
if (ctx.args.size() == 1) {
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace dropshell
|
@ -128,7 +128,7 @@ bool install_service(const std::string& server, const std::string& service, bool
|
||||
}
|
||||
|
||||
// print health tick
|
||||
std::cout << "Health: " << healthtick() << std::endl;
|
||||
std::cout << "Health: " << healthtick(server,service) << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,5 +15,8 @@ namespace dropshell {
|
||||
// defined in install.cpp
|
||||
bool install_service(const std::string& server, const std::string& service, bool silent);
|
||||
|
||||
// defined in health.cpp
|
||||
std::string healthtick(const std::string& server, const std::string& service);
|
||||
|
||||
} // namespace dropshell
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user