5#include <spdlog/spdlog.h>
16 std::string
mode =
"hybrid";
47 CLI::App app{
"Radix Relay - Hybrid Mesh Communications",
"radix-relay" };
52 app.parse(argc, argv);
53 }
catch (
const CLI::ParseError &e) {
55 std::exit(e.get_exit_code());
65 app.add_option(
"-i,--identity", args.identity_path,
"Path to identity key file");
66 app.add_option(
"-m,--mode", args.mode,
"transport mode: internet, mesh, hybrid")
67 ->check(CLI::IsMember({
"internet",
"mesh",
"hybrid" }));
68 app.add_option(
"-u,--ui", args.ui_mode,
"UI mode: tui, gui")->check(CLI::IsMember({
"tui",
"gui" }));
69 app.add_flag(
"-v,--verbose", args.verbose,
"Enable verbose logging");
70 app.add_flag(
"--version", args.show_version,
"Show version information");
72 auto *send_cmd = app.add_subcommand(
"send",
"Send a message");
73 send_cmd->add_option(
"recipient", args.send_recipient,
"Node ID or contact name")->required();
74 send_cmd->add_option(
"message", args.send_message,
"Message content")->required();
75 send_cmd->callback([&args]() { args.send_parsed =
true; });
77 auto *peers_cmd = app.add_subcommand(
"peers",
"List discovered peers");
78 peers_cmd->callback([&args]() { args.peers_parsed =
true; });
80 auto *status_cmd = app.add_subcommand(
"status",
"Show network status");
81 status_cmd->callback([&args]() { args.status_parsed =
true; });
92 if (args.mode !=
"internet" and args.mode !=
"mesh" and args.mode !=
"hybrid") {
93 spdlog::error(
"Invalid mode: {}", args.mode);
97 if (args.ui_mode !=
"tui" and args.ui_mode !=
"gui") {
98 spdlog::error(
"Invalid UI mode: {}", args.ui_mode);
102 if (args.send_parsed) {
103 if (args.send_recipient.empty()) {
104 spdlog::error(
"Send command requires recipient");
107 if (args.send_message.empty()) {
108 spdlog::error(
"Send command requires message");
auto setup_cli_app(CLI::App &app, cli_args &args) -> void
Configures CLI11 application with command-line options.
auto validate_cli_args(const cli_args &args) -> bool
Validates parsed command-line arguments for logical consistency.
auto parse_cli_args(int argc, char **argv) -> cli_args
Parses command-line arguments into a cli_args structure.
Parsed command-line arguments.
std::string identity_path
Path to identity database file.
bool show_version
Display version and exit.
std::string mode
Transport mode (internet/mesh/hybrid)
std::string ui_mode
UI mode (tui/gui)
bool peers_parsed
True if peers subcommand was used.
std::string send_message
Message content for send subcommand.
bool status_parsed
True if status subcommand was used.
bool send_parsed
True if send subcommand was used.
std::string send_recipient
Recipient for send subcommand.
bool verbose
Enable verbose logging.