Note: this project is still work in progress.
- Argument parsing
- Argument checking
- Default value
- Variable binding
- Initialize OptionParser:
OptionParser op;
- Initialize your options using the following parameters: -names -> string vector -arg -> possible values are: -OptionArg::NONE -> argument won't be taken even if it's provided -OptionArg::OPT -> argument is optional -OptionArg::REQ -> argument is required -description (optional) -> string describing the option Example:
auto xOpt = Option<int>({"x", "set-x"}, OptionArg::OPT, "set variable x");
- Add your options:
OptionParser op;
auto xOpt = Option<int>({"x", "set-x"}, OptionArg::OPT, "set variable x");
op.AddOption(&xOpt);
- Parse
OptionParser op;
auto xOpt = Option<int>({"x", "set-x"}, OptionArg::OPT, "set variable x");
op.AddOption(&xOpt);
op.Parse();
- Retrieve argument
OptionParser op;
auto xOpt = Option<int>({"x", "set-x"}, OptionArg::OPT, "set variable x");
op.AddOption(&xOpt);
op.Parse();
int x = xOpt.Value();
GoogleTest is required for building tests, it shuold be located in the lib folder. Install:
cd build
git clone https://github.com/google/googletest/