lib/cli: Add fields for a short description and additional usage information to the arguments parser

This is in preparation for building the help text generator.
BodgeMaster-unfinished
BodgeMaster 2022-08-02 02:03:50 +02:00
parent d0d02fc8d2
commit 69f15e928a
2 changed files with 13 additions and 0 deletions

View File

@ -189,6 +189,15 @@ namespace CLI {
}
}
ArgumentsParser::ArgumentsParser(int argc, const char* const argv[], std::vector<Flag> flags, std::vector<UnpositionalArgument> unpositionalArguments, std::vector<PositionalArgument> positionalArguments, std::string description): ArgumentsParser::ArgumentsParser(argc, argv, flags, unpositionalArguments, positionalArguments) {
this->description = description;
}
ArgumentsParser::ArgumentsParser(int argc, const char* const argv[], std::vector<Flag> flags, std::vector<UnpositionalArgument> unpositionalArguments, std::vector<PositionalArgument> positionalArguments, std::string description, std::string additionalInfo): ArgumentsParser::ArgumentsParser(argc, argv, flags, unpositionalArguments, positionalArguments) {
this->description = description;
this->additionalInfo = additionalInfo;
}
ArgumentsParser::~ArgumentsParser() {
//TODO: check that this actually runs
for (auto const& [shortName, flag]: this->flagsByShortName) {

View File

@ -68,6 +68,8 @@ namespace CLI {
std::map<char, UnpositionalArgument*> argumentsByShortName;
std::map<std::string, UnpositionalArgument*> argumentsByLongName;
std::vector<PositionalArgument> positionalArguments;
std::string description;
std::string additionalInfo;
public:
std::string programName;
@ -76,6 +78,8 @@ namespace CLI {
// using int here bc that's how main() is defined
ArgumentsParser(int argc, const char* const argv[], std::vector<Flag> flags, std::vector<UnpositionalArgument> unpositionalArguments, std::vector<PositionalArgument> positionalArguments);
ArgumentsParser(int argc, const char* const argv[], std::vector<Flag> flags, std::vector<UnpositionalArgument> unpositionalArguments, std::vector<PositionalArgument> positionalArguments, std::string description);
ArgumentsParser(int argc, const char* const argv[], std::vector<Flag> flags, std::vector<UnpositionalArgument> unpositionalArguments, std::vector<PositionalArgument> positionalArguments, std::string description, std::string additionalInfo);
~ArgumentsParser();
ErrorOr<bool> getFlag(char shortName);