Commit 6b95ee8ab55851cc5f5b52e0c3e419bccc620e36
Committed by
GitHub
1 parent
b65367a1
Fix logic in example 'option_groups', documentation: fix escaped colon glyph (#692)
* Documentation: fixing escaped colon sign * Example option_groups: * fix output logic * add whitespace between format_type and string "format"
Showing
2 changed files
with
5 additions
and
5 deletions
book/chapters/options.md
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | ## Simple options |
| 4 | 4 | |
| 5 | -The most versatile addition to a command line program is a option. This is like a flag, but it takes an argument. CLI11 handles all the details for many types of options for you, based on their type. To add an option: | |
| 5 | +The most versatile addition to a command line program is an option. This is like a flag, but it takes an argument. CLI11 handles all the details for many types of options for you, based on their type. To add an option: | |
| 6 | 6 | |
| 7 | 7 | ```cpp |
| 8 | 8 | int int_option{0}; |
| ... | ... | @@ -21,7 +21,7 @@ You can use any C++ int-like type, not just `int`. CLI11 understands the followi |
| 21 | 21 | | Type | CLI11 | |
| 22 | 22 | |-------------|-------| |
| 23 | 23 | | number like | Integers, floats, bools, or any type that can be constructed from an integer or floating point number. Accepts common numerical strings like `0xFF` as well as octal, and decimal | |
| 24 | -| string-like | std\::string, or anything that can be constructed from or assigned a std\::string | | |
| 24 | +| string-like | std::string, or anything that can be constructed from or assigned a std::string | | |
| 25 | 25 | | char | For a single char, single string values are accepted, otherwise longer strings are treated as integral values and a conversion is attempted | |
| 26 | 26 | | complex-number | std::complex or any type which has a real(), and imag() operations available, will allow 1 or 2 string definitions like "1+2j" or two arguments "1","2" | |
| 27 | 27 | | enumeration | any enum or enum class type is supported through conversion from the underlying type(typically int, though it can be specified otherwise) | | ... | ... |
examples/option_groups.cpp
| ... | ... | @@ -33,10 +33,10 @@ int main(int argc, char **argv) { |
| 33 | 33 | CLI11_PARSE(app, argc, argv); |
| 34 | 34 | |
| 35 | 35 | std::string format_type = (csv) ? std::string("CSV") : ((human) ? "human readable" : "binary"); |
| 36 | - std::cout << "Selected " << format_type << "format" << std::endl; | |
| 37 | - if(fileLoc.empty()) { | |
| 36 | + std::cout << "Selected " << format_type << " format" << std::endl; | |
| 37 | + if(!fileLoc.empty()) { | |
| 38 | 38 | std::cout << " sent to file " << fileLoc << std::endl; |
| 39 | - } else if(networkAddress.empty()) { | |
| 39 | + } else if(!networkAddress.empty()) { | |
| 40 | 40 | std::cout << " sent over network to " << networkAddress << std::endl; |
| 41 | 41 | } else { |
| 42 | 42 | std::cout << " sent to std::cout" << std::endl; | ... | ... |