C3/Src/ChannelLinter/ArgumentParser.h

40 lines
949 B
C
Raw Normal View History

2019-11-07 16:21:44 +00:00
#pragma once
namespace MWR::C3::Linter
{
2019-11-18 12:57:56 +00:00
/// Channel linter command line arguments parser
2019-11-07 16:21:44 +00:00
class ArgumentParser
{
public:
2019-11-18 12:57:56 +00:00
/// Parse and validate arguments
/// @param argc - number of arguments
/// @param argv - vector of arguments
/// @throws std::invalid_argument if config is not valid
2019-11-07 16:21:44 +00:00
ArgumentParser(int argc, char** argv);
2019-11-25 11:22:41 +00:00
/// @returns valid application config
2019-11-18 12:57:56 +00:00
AppConfig const& GetConfig() const;
2019-11-07 16:21:44 +00:00
2019-11-18 12:57:56 +00:00
/// @returns formatted usage string
2019-11-07 16:21:44 +00:00
std::string GetUsage() const;
private:
2019-11-18 12:57:56 +00:00
/// Helper to configure internal parser
2019-11-07 16:21:44 +00:00
void ConfigureParser();
2019-11-18 12:57:56 +00:00
/// Helper create AppConfig
AppConfig CreateConfig() const;
2019-11-25 11:22:41 +00:00
/// Validate created config, uses ArgumentParser options in messages
/// @throws std::invalid_argument if config is not valid
void ValidateConfig() const;
2019-11-18 12:57:56 +00:00
/// Internal argument parser
2019-11-07 16:21:44 +00:00
argparse::ArgumentParser m_ArgParser;
2019-11-18 12:57:56 +00:00
/// Holds an application config, once arguments
AppConfig m_Config;
2019-11-07 16:21:44 +00:00
};
}