This commit is contained in:
Leonetienne 2021-06-08 14:01:50 +02:00
parent 4382254218
commit aa7957f12d

View File

@ -1,7 +1,7 @@
[![Hazelnupp](https://raw.githubusercontent.com/Leonetienne/Hazelnupp/master/Brand/nupp.png)](https://github.com/Leonetienne/Hazelnupp) [![Hazelnupp](https://raw.githubusercontent.com/Leonetienne/Hazelnupp/master/Brand/nupp.png)](https://github.com/Leonetienne/Hazelnupp)
# [Documentation](https://leonetienne.github.io/Hazelnupp/) # [Documentation](https://leonetienne.github.io/Hazelnupp/)
## [Direct link to docs of the main class](https://leonetienne.github.io/Hazelnupp/classHazelnupp.html) ## [Direct link to docs of the main class](https://leonetienne.github.io/Hazelnupp/classCmdArgsInterface.html)
# Hazelnupp # Hazelnupp
is a simple, easy to use command line parameter parser. is a simple, easy to use command line parameter parser.
@ -20,7 +20,7 @@ $ a.out -lp 1234
These examples reference exceptions. These are not enabled by default. The default behaviour for user-fault exceptions is to produce output to `stderr` and kill the process. These examples reference exceptions. These are not enabled by default. The default behaviour for user-fault exceptions is to produce output to `stderr` and kill the process.
To enable exceptions, call this method: To enable exceptions, call this method:
```cpp ```cpp
Hazelnupp args; CmdArgsInterface args;
args.SetCrashOnFail(false); args.SetCrashOnFail(false);
``` ```
@ -86,7 +86,7 @@ using namespace Hazelnp;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
Hazelnupp args(argc, argv); CmdArgsInterface args(argc, argv);
if (args.HasParam("--force")) if (args.HasParam("--force"))
// do forced // do forced
@ -104,7 +104,7 @@ using namespace Hazelnp;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
Hazelnupp args(argc, argv); CmdArgsInterface args(argc, argv);
// Either check via HasParam(), or do a try-catch // Either check via HasParam(), or do a try-catch
try try
@ -129,7 +129,7 @@ using namespace Hazelnp;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
Hazelnupp args(argc, argv); CmdArgsInterface args(argc, argv);
const auto& myList = args["--my-list"].GetList(); // std::vector<Value*> const auto& myList = args["--my-list"].GetList(); // std::vector<Value*>
@ -153,7 +153,7 @@ using namespace Hazelnp;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
Hazelnupp args; CmdArgsInterface args;
// Register abbreviations // Register abbreviations
args.RegisterAbbreviation("-f", "--force"); args.RegisterAbbreviation("-f", "--force");
@ -188,7 +188,7 @@ using namespace Hazelnp;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
Hazelnupp args; CmdArgsInterface args;
// Register constraints // Register constraints
args.RegisterConstraint("--this-is-required", ParamConstraint::Require()); // This missing throws an exception args.RegisterConstraint("--this-is-required", ParamConstraint::Require()); // This missing throws an exception
@ -225,7 +225,7 @@ using namespace Hazelnp;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
Hazelnupp args; CmdArgsInterface args;
// Register constraints // Register constraints
args.RegisterConstraint("--this-must-be-int", ParamConstraint::TypeSafety(DATA_TYPE::INT)); args.RegisterConstraint("--this-must-be-int", ParamConstraint::TypeSafety(DATA_TYPE::INT));
@ -257,7 +257,7 @@ What doesn't work is inserting multiple constraints for one key. It will just di
Hazelnupp does automatically create a parameter documentation, accessible via `--help`. Hazelnupp does automatically create a parameter documentation, accessible via `--help`.
If you want to use `--help` yourself, just turn it off. If you want to use `--help` yourself, just turn it off.
```cpp ```cpp
Hazelnupp args; CmdArgsInterface args;
args.SetCatchHelp(false); args.SetCatchHelp(false);
``` ```
@ -285,13 +285,13 @@ This is the testing application for Hazelnupp.
This documentation is automatically fed by any information provided on parameters. This documentation is automatically fed by any information provided on parameters.
You have to set the brief descriptions yourself though. You have to set the brief descriptions yourself though.
```cpp ```cpp
Hazelnupp args; CmdArgsInterface args;
args.RegisterDescription("--force", "Just forces it."); args.RegisterDescription("--force", "Just forces it.");
``` ```
Additionally you can provide a brief description of your application to be added right above the parameter list. Additionally you can provide a brief description of your application to be added right above the parameter list.
```cpp ```cpp
Hazelnupp args; CmdArgsInterface args;
args.SetBriefDescription("This is the testing application for Hazelnupp."); args.SetBriefDescription("This is the testing application for Hazelnupp.");
``` ```