argparse.h
- 2 minsA simple header only command line argument parser
You can follow the project’s Github page here
Master | Develop |
---|---|
Table of Contents
Building With Git and CMake
Make
git clone https://github.com/jamolnng/argparse.git
cd argparse
mkdir build && cd build
cmake ..
make
VSCode and CMake Tools
VSCode and CMake Tools extension
TODO
Visual Studio
TODO
Usage
#include "argparse.h"
#include <iostream>
int main(int argc, char* argv[]) {
ArgumentParser parser("Argument parser example");
parser.add_argument("-v", // short argument
"--verbose", // long argument
"Verbose level", // description
false // is required
);
parser.parse(argc, argv);
if (parser.exists("verbose")) {
switch (parser.get<unsigned int>("verbose")) {
case 2:
std::cout << "an even more verbose string" << std::endl;
case 1:
std::cout << "a verbose string" << std::endl;
default:
std::cout << "some verbosity" << std::endl;
}
}
}
Example output:
> program -v 2
an even more verbose string
a verbose string
some verbosity
> program --verbose
some verbosity
Running Tests
Make
make test
###
VSCode and CMake Tools
TODO
Visual Studio
TODO
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.