https://github.com/zheoni/parsegar
Another and worse C++ command line argument parser
https://github.com/zheoni/parsegar
argument-parser command-line-parser cpp parser
Last synced: 8 months ago
JSON representation
Another and worse C++ command line argument parser
- Host: GitHub
- URL: https://github.com/zheoni/parsegar
- Owner: Zheoni
- License: mit
- Created: 2019-08-24T14:00:49.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-03T14:53:27.000Z (over 6 years ago)
- Last Synced: 2025-01-20T06:24:01.414Z (over 1 year ago)
- Topics: argument-parser, command-line-parser, cpp, parser
- Language: C++
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PARSEGAR
This is another and worse C++ parser for the command line arguments.
I have done this so simple and basic because I need it for other
projects, therefore it lacks some features, but it may be updated in
the future.
## Usage
Include the `parsegar.hpp` header file. To set your arguments or flags
create a argsConfig object and use addFlag or addArgument to add them.
Next create a argsParser object with the config object, argc and argv.
**This can throw exceptions** (std::runtime_error) if the input has errors.
A simple example:
```c++
#include "parsegar.hpp"
#include
int main(int argc, const char** argv) {
argsConfig config;
config.addFlag("-a");
config.addFlag("-h");
config.addArgument("-o");
argsParser parser(config, argc, argv);
std::cout << "-a: " << parser.getFlag("-a") << std::endl;
std::cout << "-h: " << parser.getFlag("-h") << std::endl;
std::cout << "-o: " << parser.getArgument("-o") << std::endl;
}
```
## Compiling
Requires **c++11** at least. You have to also compile `parsegar.cpp`.
For example the above example is compiled with the following command:
`clang++ -std=c++11 parsegar.cpp main.cpp`