Skip to content

Commit 8e08317

Browse files
committed
Fix GitHub Issue #5: Add documentation of option info texts
1 parent c3f71f3 commit 8e08317

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,37 @@ In order to mark an option mandatory, there's an overload that accepts `bool req
216216
...
217217
```
218218

219+
## General: Adding option documentation for the auto-generated help
220+
221+
One can add option documentation for the auto-generated help.
222+
223+
Consider this example code:
224+
225+
```
226+
...
227+
228+
juzzlin::Argengine ae(argc, argv);
229+
ae.addOption(
230+
{ "-p" }, [](std::string value) {
231+
std::cout << value.size() << std::endl;
232+
},
233+
true, "Print length of given text. This option is required.", "TEXT");
234+
235+
...
236+
```
237+
238+
Here we have added a documentation string `Print length of given text. This option is required.` and also a variable name `TEXT` for option `-p`.
239+
240+
Thus, this will generate a help content like this:
241+
242+
```
243+
Options:
244+
245+
-h, --help Show this help.
246+
-p [TEXT] Print length of given text. This option is required.
247+
248+
```
249+
219250
## General: Error handling
220251

221252
For error handling there are two options: exceptions or error value.

src/examples/ex1/ex1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int main(int argc, char ** argv)
4343
{ "-p" }, [](std::string value) {
4444
std::cout << value.size() << std::endl;
4545
},
46-
true, "Print length of given text. This is required", "TEXT");
46+
true, "Print length of given text. This option is required.", "TEXT");
4747

4848
Argengine::Error error;
4949
ae.parse(error);

0 commit comments

Comments
 (0)