refactor(cli): migrate runtime and simulator parsers to CLI11
Replace hand-rolled argument parsing with CLI11-backed parse paths for streamer runtime config and simulator runtime options. Simulator help text is now generated from CLI11 app definitions to keep parser/help output in sync, while preserving legacy validation messages and exit semantics used by automation.
This commit is contained in:
@@ -4,33 +4,50 @@
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "cvmmap_streamer/ipc/contracts.hpp"
|
||||
|
||||
namespace cvmmap_streamer::sim {
|
||||
|
||||
struct RuntimeConfig {
|
||||
std::uint32_t frames{360};
|
||||
std::uint32_t fps{60};
|
||||
std::uint16_t width{64};
|
||||
std::uint16_t height{48};
|
||||
std::optional<std::uint32_t> emit_reset_at{};
|
||||
std::optional<std::uint32_t> emit_reset_every{};
|
||||
std::optional<std::uint32_t> switch_format_at{};
|
||||
std::optional<std::uint16_t> switch_width{};
|
||||
std::optional<std::uint16_t> switch_height{};
|
||||
std::string label{"sim"};
|
||||
std::string shm_name{"cvmmap_sim"};
|
||||
std::string zmq_endpoint{"ipc:///tmp/cvmmap_sim"};
|
||||
std::uint8_t channels{3};
|
||||
ipc::Depth depth{ipc::Depth::U8};
|
||||
ipc::PixelFormat pixel_format{ipc::PixelFormat::BGR};
|
||||
std::uint32_t frames{360};
|
||||
std::uint32_t fps{60};
|
||||
std::uint16_t width{64};
|
||||
std::uint16_t height{48};
|
||||
std::optional<std::uint32_t> emit_reset_at{};
|
||||
std::optional<std::uint32_t> emit_reset_every{};
|
||||
std::optional<std::uint32_t> switch_format_at{};
|
||||
std::optional<std::uint16_t> switch_width{};
|
||||
std::optional<std::uint16_t> switch_height{};
|
||||
std::string label{"sim"};
|
||||
std::string shm_name{"cvmmap_sim"};
|
||||
std::string zmq_endpoint{"ipc:///tmp/cvmmap_sim"};
|
||||
std::uint8_t channels{3};
|
||||
ipc::Depth depth{ipc::Depth::U8};
|
||||
ipc::PixelFormat pixel_format{ipc::PixelFormat::BGR};
|
||||
|
||||
[[nodiscard]]
|
||||
std::uint32_t payload_size_bytes() const;
|
||||
[[nodiscard]]
|
||||
std::uint32_t payload_size_bytes() const;
|
||||
};
|
||||
|
||||
std::expected<RuntimeConfig, std::string> parse_runtime_config(int argc, char **argv);
|
||||
void print_help();
|
||||
enum class ParseStatus {
|
||||
Ok,
|
||||
Help,
|
||||
Error,
|
||||
};
|
||||
|
||||
}
|
||||
struct ParseResult {
|
||||
ParseStatus status{ParseStatus::Ok};
|
||||
RuntimeConfig config{};
|
||||
std::string message{};
|
||||
int exit_code{0};
|
||||
};
|
||||
|
||||
std::expected<RuntimeConfig, std::string> parse_runtime_config(int argc,
|
||||
char **argv);
|
||||
void print_help();
|
||||
ParseResult parse_runtime_config_with_cli11(
|
||||
int argc, char **argv, std::string_view executable_name = "cvmmap_sim");
|
||||
|
||||
} // namespace cvmmap_streamer::sim
|
||||
|
||||
Reference in New Issue
Block a user