Commit 78dc2a5b926ce61dbed3c8b727384580fd61be0b
1 parent
2c431f16
Mention of rang library
Showing
1 changed file
with
16 additions
and
0 deletions
README.md
| @@ -199,3 +199,19 @@ app.add_option("--fancy-count", [](std::vector<std::vector<std::string>> val){ | @@ -199,3 +199,19 @@ app.add_option("--fancy-count", [](std::vector<std::vector<std::string>> val){ | ||
| 199 | 199 | ||
| 200 | To contribute, open an [issue](https://github.com/henryiii/CLI11/issues) or [pull request](https://github.com/henryiii/CLI11/pulls) on GitHub, or ask a question on [gitter](https://gitter.im/CLI11gitter/Lobby). | 200 | To contribute, open an [issue](https://github.com/henryiii/CLI11/issues) or [pull request](https://github.com/henryiii/CLI11/pulls) on GitHub, or ask a question on [gitter](https://gitter.im/CLI11gitter/Lobby). |
| 201 | 201 | ||
| 202 | +## Other libraries | ||
| 203 | + | ||
| 204 | +If you use the [`rang`](https://github.com/agauniyal/rang/wiki) library to add color to your terminal in a safe, multi-platform way, you can combine it with CLI11 nicely: | ||
| 205 | + | ||
| 206 | +``` | ||
| 207 | +std::atexit([](){std::cout << rang::style::reset;}); | ||
| 208 | +try { | ||
| 209 | + app.parse(argc, argv); | ||
| 210 | +} catch (const CLI::ParseError &e) { | ||
| 211 | + std::cout << (e.exit_code==0 ? rang::fg::blue : rang::fg::red); | ||
| 212 | + return app.exit(e); | ||
| 213 | +} | ||
| 214 | +``` | ||
| 215 | + | ||
| 216 | +This will print help in blue, errors in red, and will reset before returning the terminal to the user. | ||
| 217 | + |