 |
Leonetienne/Hazelnupp
Simple, easy to use, command line parameter interface
|
Go to the documentation of this file.
4 #include <unordered_map>
15 Hazelnupp(
const int argc,
const char*
const* argv);
20 void Parse(
const int argc,
const char*
const* argv);
29 bool HasParam(
const std::string& key)
const;
75 const std::string
GetDescription(
const std::string& parameter)
const;
85 void PopulateRawArgs(
const int argc,
const char*
const* argv);
88 void ExpandAbbreviations();
91 std::size_t ParseNextParameter(
const std::size_t parIndex,
Parameter*& out_Par);
94 Value* ParseValue(
const std::vector<std::string>& values,
const ParamConstraint* constraint =
nullptr);
97 void ApplyConstraints();
100 const ParamConstraint* GetConstraintForKey(
const std::string& key)
const;
102 std::string executableName;
103 std::unordered_map<std::string, Parameter*> parameters;
106 std::unordered_map<std::string, std::string> abbreviations;
109 std::unordered_map<std::string, ParamConstraint> constraints;
112 std::vector<std::string> rawArgs;
115 std::unordered_map<std::string, std::string> parameterDescriptions;
118 std::string briefDescription;
121 bool catchHelp =
true;
124 bool crashOnFail =
true;
const std::string & GetBriefDescription()
Returns the brief description of the application to be automatically added to the documentation.
void ClearConstraints()
Will delete all constraints.
const std::string & GetExecutableName() const
Will return argv[0], the name of the executable.
std::string GenerateDocumentation() const
Will generate a text-based documentation suited to show the user, for example on –help.
const Value & operator[](const std::string &key) const
Will return the value given a key.
The main class to interface with.
void ClearAbbreviations()
Will delete all abbreviations.
void SetBriefDescription(const std::string &description)
Sets a brief description of the application to be automatically added to the documentation.
Abstract class for values.
bool GetCrashOnFail() const
Gets whether the application crashes on an exception whilst parsing, and prints to stderr.
void SetCatchHelp(bool catchHelp)
Sets whether the Hazelnupp should automatically catch the –help parameter, print the parameter docume...
bool GetCatchHelp() const
Retruns whether the Hazelnupp should automatically catch the –help parameter, print the parameter doc...
bool HasParam(const std::string &key) const
Will check wether a parameter exists given a key, or not.
void Parse(const int argc, const char *const *argv)
Will parse command line arguments.
void RegisterAbbreviation(const std::string &abbrev, const std::string &target)
Will register an abbreviation (like -f for –force)
void RegisterConstraints(const std::vector< ParamConstraint > &constraints)
Will register parameter constraints.
const std::string & GetAbbreviation(const std::string &abbrev) const
Will return the long form of an abbreviation (like –force for -f)
void ClearDescription(const std::string ¶meter)
Will delete the description of a parameter if it exists.
bool HasAbbreviation(const std::string &abbrev) const
Will check wether or not an abbreviation is registered.
void SetCrashOnFail(bool crashOnFail)
Sets whether to crash the application, and print to stderr, when an exception is raised whilst parsin...
void RegisterDescription(const std::string ¶meter, const std::string &description)
Willl register a short description for a parameter.
const std::string GetDescription(const std::string ¶meter) const
Will return a short description for a parameter, if it exists.