test_123/include/adapter.hpp

63 lines
1.5 KiB
C++
Raw Normal View History

2026-05-16 04:54:48 +00:00
#ifndef MODULAR_ADAPTER_HPP
#define MODULAR_ADAPTER_HPP
#include <string>
#include <vector>
#include <memory>
/**
* @brief Parsed command-line arguments.
*/
struct CommandLineArgs {
std::string config_path; ///< Path to config file (--config <path>).
bool show_help = false; ///< Whether --help was passed.
bool show_version = false; ///< Whether --version was passed.
bool has_errors = false; ///< Whether there were parsing errors.
std::string error_msg; ///< Error message if has_errors is true.
};
/**
* @brief Adapter for parsing CLI arguments and dispatching commands.
*
* Supports:
* --config <path> Load configuration from file
* --help Display help message
* --version Display application version
*/
class CommandLineAdapter {
public:
/**
* @brief Construct the adapter with argc/argv.
* @param argc Argument count (from main).
* @param argv Argument vector (from main).
*/
CommandLineAdapter(int argc, char* argv[]);
/**
* @brief Parse the stored arguments.
* @return A CommandLineArgs struct containing parsed values.
*/
CommandLineArgs parse();
/**
* @brief Print the help message to stdout.
*/
static void printHelp();
/**
* @brief Print the version string to stdout.
*/
static void printVersion();
private:
int argc_;
char** argv_;
/**
* @brief Get argument at index i, or empty string if out of range.
*/
std::string argAt(int i) const;
};
#endif // MODULAR_ADAPTER_HPP