Welcome to GetOpt++’s documentation!¶
Contents:
Introduction¶
Intent¶
GetOpt++ is C++ library for command line argument parsing. Core values of the project are:
- Performance
- Simplicity
- Clarity
Okay, enough of buzzwords - this library should be easy to deploy - performance and documentation are secondary values (at least for the time being). Our mission is to make life easier. Not neccessarily by coming up with something mind-blowing.
Setup¶
How to get going¶
- git clone https://github.com/PiotrOsiewicz/GetOptPlusPlus
- cd GetOptPlusPlus
- sudo make install
Prequisites¶
This library is being developed on Linux and so I cannot guarantee that it will work on other operating systems. It does not make use of any propriertary system libraries.
It requires:
- C++11-compatible compiler.
- Criterion unit testing library (if running tests).
API quick reference¶
-
class
GOpp::
Parser
¶
Intent
Parser is the object that user should interact with. Its responsibilites include:
- parsing arguments and assigning them to appropiate parameters.
- providing interface to check state of parsed arguments.
Assumptions
After being handed command line arguments in constructor, Parser should not be mutated in any way. It can be thought of as a container (and interpreter) for Command objects.
-
GOpp::Parser::
Parser
(const std::vector<std::string> Parameters, const std::vector<Command::Definition> CommandParameters)¶ Parameters: - Parameters – Command line parameters. Size will be deduced from vector size.
- CommandParameters – Definitions of viable parameters, along with their accepted arguments and flags.
Returns: None:
Throws: - invalid_argument – If ‘argc’ is smaller than 1.
- logic_error – If CommandParameters Contains clashing names.
-
GOpp::Parser::
Parser
(const std::initializer_list<std::string> Parameters, const std::initializer_list<Command::Definition> CommandParameters)¶ Delegates work to vector-based constructor.
Parameters: - Parameters – Command line parameters. Size will be deduced from container size.
- CommandParameters – Definitions of viable parameters, along with their accepted arguments and flags.
Returns: None
Throws: - invalid_argument – If argc is smaller than 1.
- logic_error – If CommandParameters contains clashing names.
-
GOpp::Parser::
Parser
(int argc, char **argv, const std::initializer_list<Command::Definition> CommandParameters)¶ Uses C-style arguments and molds them to fit initializer-list constructor.
Parameters: - argc – Argument count.
- argv – C-style string argument array.
- CommandParameters – Definitions of viable parameters, along with their accepted arguments and flags.
Returns: None:
Throws: - invalid_argument – If argc is smaller than 1.
- logic_error – If CommandParameters contains clashing names.
FAQ¶
Ask away, we’ll fill it gradually.