Radix Relay
Hybrid mesh communications with Signal Protocol encryption
Loading...
Searching...
No Matches
app_init.hpp
Go to the documentation of this file.
1#pragma once
2
7#include <core/events.hpp>
9#include <fmt/core.h>
10#include <memory>
11#include <spdlog/spdlog.h>
12#include <string>
13
15
20{
21 std::string node_fingerprint;
22 std::string mode;
23 std::string identity_path;
24};
25
32inline auto configure_logging(const cli_args &args,
33 std::shared_ptr<async::async_queue<core::events::display_filter_input_t>> display_queue = nullptr) -> void
34{
35 if (display_queue) {
36 auto tui_sink = std::make_shared<tui_sink_mutex_t>(display_queue);
37 auto logger = std::make_shared<spdlog::logger>("tui_logger", tui_sink);
38 spdlog::set_default_logger(logger);
39 }
40
41 if (args.verbose) { spdlog::set_level(spdlog::level::debug); }
42}
43
49inline auto print_app_banner(const app_state &state) -> void
50{
51 fmt::print("Radix Relay v{} - Interactive Mode\n", radix_relay::cmake::project_version);
52 fmt::print("Node: {} ({})\n", state.node_fingerprint, state.identity_path);
53 fmt::print("transport: {}\n", state.mode);
54 fmt::print("Connected Peers: 0 (transport layer not implemented)\n\n");
55}
56
60inline auto print_available_commands() -> void
61{
62 fmt::print(
63 "Available commands: send, broadcast, peers, status, sessions, mode, scan, connect, trust, verify, version, help, "
64 "quit\n\n");
65}
66
75template<concepts::command_handler CmdHandler>
76[[nodiscard]] inline auto execute_cli_command(const cli_args &args, std::shared_ptr<CmdHandler> command_handler) -> bool
77{
78
79 if (args.show_version) {
80 command_handler->handle(radix_relay::core::events::version{});
81 return true;
82 }
83
84 if (args.send_parsed) {
85 command_handler->handle(
86 radix_relay::core::events::send{ .peer = args.send_recipient, .message = args.send_message });
87 return true;
88 }
89
90 if (args.peers_parsed) {
91 command_handler->handle(radix_relay::core::events::peers{});
92 return true;
93 }
94
95 if (args.status_parsed) {
96 command_handler->handle(radix_relay::core::events::status{});
97 return true;
98 }
99
100 return false;
101}
102
103}// namespace radix_relay::cli_utils
Thread-safe asynchronous queue for message passing between coroutines.
Custom spdlog sink that routes log messages to a display queue.
Definition tui_sink.hpp:20
auto configure_logging(const cli_args &args, std::shared_ptr< async::async_queue< core::events::display_filter_input_t > > display_queue=nullptr) -> void
Configures spdlog logging based on CLI arguments.
Definition app_init.hpp:32
auto print_available_commands() -> void
Prints list of available interactive commands.
Definition app_init.hpp:60
auto print_app_banner(const app_state &state) -> void
Prints the application startup banner.
Definition app_init.hpp:49
auto execute_cli_command(const cli_args &args, std::shared_ptr< CmdHandler > command_handler) -> bool
Executes a command specified via CLI arguments.
Definition app_init.hpp:76
Runtime application state.
Definition app_init.hpp:20
std::string identity_path
Path to identity database.
Definition app_init.hpp:23
std::string mode
Current transport mode.
Definition app_init.hpp:22
std::string node_fingerprint
Signal Protocol node fingerprint.
Definition app_init.hpp:21
Parsed command-line arguments.
Request list of connected peers.
Definition events.hpp:20
Send encrypted message to a specific peer.
Definition events.hpp:56
std::string peer
RDX fingerprint or alias of recipient.
Definition events.hpp:57
Request current system status.
Definition events.hpp:25
Request application version information.
Definition events.hpp:45