-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHealthCommand.cpp
More file actions
76 lines (64 loc) · 1.88 KB
/
Copy pathHealthCommand.cpp
File metadata and controls
76 lines (64 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
*
* @file HealthCommand.cpp
* @author Gaspard Kirira
*
* Copyright 2026, Gaspard Kirira. All rights reserved.
* https://github.com/vixcpp/vix
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Vix.cpp
*/
#include <vix/cli/commands/HealthCommand.hpp>
#include <vix/cli/commands/health/HealthChecker.hpp>
#include <vix/cli/commands/health/HealthConfig.hpp>
#include <vix/cli/commands/health/HealthOutput.hpp>
#include <iostream>
#include <string>
#include <vector>
namespace vix::commands
{
int HealthCommand::run(const std::vector<std::string> &args)
{
if (args.empty())
{
const auto cfg = health::load_health_config();
return health::checker::check_all(cfg);
}
if (args[0] == "-h" || args[0] == "--help")
return help();
const auto cfg = health::load_health_config();
const std::string action = args[0];
if (action == "local")
return health::checker::check_local(cfg);
if (action == "public")
return health::checker::check_public(cfg);
if (action == "websocket" || action == "ws")
return health::checker::check_websocket(cfg);
health::output::error(
std::cerr,
"unknown health command: " + action);
health::output::fix(
std::cerr,
"vix health --help");
return 1;
}
int HealthCommand::help()
{
std::cout
<< "Usage:\n"
<< " vix health [command]\n\n"
<< "Commands:\n"
<< " local Check the local application endpoint\n"
<< " public Check the public HTTPS endpoint\n"
<< " websocket Check the WebSocket endpoint\n"
<< " ws Alias for websocket\n\n"
<< "Examples:\n"
<< " vix health\n"
<< " vix health local\n"
<< " vix health public\n"
<< " vix health websocket\n";
return 0;
}
}