 |
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;
88 const std::string&
GetDescription(
const std::string& parameter)
const;
104 void PopulateRawArgs(
const int argc,
const char*
const* argv);
107 void ExpandAbbreviations();
110 std::size_t ParseNextParameter(
const std::size_t parIndex,
Parameter*& out_Par);
113 Value* ParseValue(
const std::vector<std::string>& values,
const ParamConstraint* constraint =
nullptr);
116 void ApplyConstraints();
119 const ParamConstraint* GetConstraintForKey(
const std::string& key)
const;
121 std::string executableName;
122 std::unordered_map<std::string, Parameter*> parameters;
125 std::unordered_map<std::string, std::string> parameterAbreviations;
128 std::unordered_map<std::string, ParamConstraint> parameterConstraints;
131 std::vector<std::string> rawArgs;
135 std::unordered_map<std::string, std::string> parameterDescriptions;
138 std::string briefDescription;
141 bool catchHelp =
true;
144 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.
ParamConstraint GetConstraint(const std::string ¶meter) const
Will return the constraint information for a specific parameter.
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.
bool HasDescription(const std::string ¶meter) const
Returns whether or not a given parameter has a registered description.
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 ClearDescription(const std::string ¶meter)
Will delete the description of a parameter if it exists.
void RegisterAbbreviation(const std::string &abbrev, const std::string &target)
Will register an abbreviation (like -f for –force)
const std::string & GetAbbreviation(const std::string &abbrev) const
Will return the long form of an abbreviation (like –force for -f) Returns "" if no match is found.
void ClearDescriptions()
Will delete all parameter descriptions.
void RegisterConstraint(const std::string &key, const ParamConstraint &constraint)
Will register a constraint for a parameter.
const std::string & GetDescription(const std::string ¶meter) const
Will return a short description for a parameter, if it exists.
void ClearConstraint(const std::string ¶meter)
Will the constraint of a specific parameter.
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.
void ClearAbbreviation(const std::string &abbrevation)
Will delete the abbreviation for a given parameter.