https://github.com/wallix/program_options
Parse command-line options
https://github.com/wallix/program_options
Last synced: 24 days ago
JSON representation
Parse command-line options
- Host: GitHub
- URL: https://github.com/wallix/program_options
- Owner: wallix
- License: lgpl-2.1
- Created: 2015-08-12T15:36:55.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-03-23T14:52:14.000Z (over 9 years ago)
- Last Synced: 2025-02-21T23:48:01.729Z (over 1 year ago)
- Language: C++
- Size: 35.2 KB
- Stars: 0
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Parse command-line options (C++11).
# Examples
```c++
int main(int ac, char ** av) {
namespace po = program_options;
std::string in;
po::options_description desc({
{'v', "verbose", "For more verbose basic debugging"},
{"no-message", "Suppress error"},
{'a', "Build all targets"},
{'x', "xxx", ""/*no desciption*/},
{"in", &in, "input file"},
});
auto map = po::parse_command_line(ac, av, desc);
if (!map.count("in")) {
std::cerr << "blah blah\n\n" << desc;
return 1;
}
std::cout << "in: " << in << "\n";
...
return 0;
}
```
# Exceptions
- `program_options::unknown_option`
- `program_options::invalid_option_value`
- `program_options::invalid_command_line_syntax`
# Tests
`$ bjam test_program_options`
# Install libraries
`$ bjam install`
or
`$ bjam install link=static`
This command make two directories: `lib` and `include/program_options`.
Paths configurable with `LIB_PREFIX` and `INCLUDE_PREFIX` variables environment.
`$ LIB_PREFIX=/usr/local/lib INCLUDE_PREFIX=/usr/local/include/program_options bjam install`
# Package
With Wallix packager (https://github.com/wallix/packager).
`$ $PACKAGER_PROJECT/packager.py --version 1.0 --no-entry-changelog`
`$ dpkg-buildpackage -I.git -Ibin -uc -us`