https://github.com/antonako1/arghand
Single header argument parsing and handling library made with C++11
https://github.com/antonako1/arghand
cpp library
Last synced: 11 months ago
JSON representation
Single header argument parsing and handling library made with C++11
- Host: GitHub
- URL: https://github.com/antonako1/arghand
- Owner: Antonako1
- License: bsd-2-clause
- Created: 2025-06-15T17:44:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-09T22:32:32.000Z (12 months ago)
- Last Synced: 2025-07-10T04:54:03.132Z (12 months ago)
- Topics: cpp, library
- Language: C++
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Arghand - Argument handling single header library made with C++11
## Usage and documentation
### Documentation
Read Arghand\include\Arghand.h for documentation
### Example program
```cpp
#include
int main(int argc, char* argv[]) {
Arghand handler;
std::vector options = {
CMD_OPTION("h", "help", HelpOptionDefault, "", "Display help information"),
CMD_OPTION("v", "", VersionOptionDefault, "", "Display version information"),
CMD_OPTION("o", "output", InputDefault, "output.txt", "Specify output file"),
CMD_OPTION("l", "list", ListInputDefault, "a,b", "Specify a list of values (comma-separated)"),
};
handler.SetCmdOptions(options);
handler.SetSeparator(',');
handler.SetParserOptions(
(ParserOptions::DefaultOptions |
ParserOptions::VersionDisplayFooter )
// & ~ParserOptions::HelpDisplayHeader
);
handler.SetApplicationName("Arghand-test_app");
handler.SetHelpHeader("Arghand - A simple command line argument handler.");
handler.SetHelpFooter("\nMaintained at https://github.com/Antonako1/Arghand.");
handler.SetLicense("Licensed under the BSD-2-Clause License.");
handler.SetVersion(handler.VersionNumToString(1, 0, 0));
handler.SetVersionFooter("Maintained at https://github.com/Antonako1/Arghand.");
Arghand::ParseResult res = handler.parse(argc, argv);
if(res == Arghand::ParseResult::Error){
std::cerr << "Error parsing command line arguments." << std::endl;
return 1;
}
if(handler["o"]){
std::cout << "Output file specified: " << handler.GetValue("o") << std::endl;
} else if(handler["list"]){
std::vector listValues = handler.GetValues("l");
std::cout << "List values specified: ";
for (const auto& value : listValues) {
std::cout << value << ", ";
}
std::cout << std::endl;
}
return 0;
}
```