Skip to content

Commit dc33874

Browse files
committed
Update README.md
1 parent 624b8a4 commit dc33874

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

README.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Single value:
9292

9393
There can be as many argument variants as liked, usually the short and long version e.g `-f` and `--foo`.
9494

95-
Argengine doesn't care about the naming of the options and they can be anything: `-f`, `a`, `/c`, `foo`, `--foo`..
95+
`Argengine` doesn't care about the naming of the options and they can be anything: `-f`, `a`, `/c`, `foo`, `--foo` ...
9696

9797
Positional arguments (for example a file name for a text editor after other options) can be received with a single callback:
9898

@@ -110,14 +110,52 @@ Positional arguments (for example a file name for a text editor after other opti
110110

111111
If callback for positional arguments is set, then no errors about `unknown options` will occur as all additional options will be taken as positional arguments.
112112

113+
# Help
114+
115+
By default, `Argengine` will create a simple help that is shown with `-h` or `--help`.
116+
117+
Without any additional options possible output will look like this:
118+
119+
```
120+
Usage: ./ex1 [OPTIONS]
121+
122+
Options:
123+
124+
-h, --help Show this help.
125+
```
126+
127+
The help can be manually printed with `Argengine::printHelp()`.
128+
129+
The default help can be disabled by constructing `Argengine` with `Argengine::Argengine(argc, argv, false)`.
130+
131+
## Custom help
132+
133+
A custom help can be added with:
134+
135+
`void Argengine::addHelp(OptionVariants optionVariants, ValuelessCallback callback)`
136+
137+
You'd still very likely want to call `Argengine::printHelp()` in the callback and just add some stuff around it.
138+
139+
## Sorting order of options
140+
141+
The sorting order of options can be selected with:
142+
143+
`void Argengine::setHelpSorting(HelpSorting helpSorting)`
144+
145+
## Custom help text
146+
147+
The text printed before options can be set with:
148+
149+
`void Argengine::setHelpText(std::string helpText)`
150+
113151
# Examples
114152

115153
## Valueless options: The simplest possible example
116154

117155
Valueless options are options without any value, so they are just flags. The lambda callback is of the form `[] {}`.
118156

119157
```
120-
#include "argengine.hpp"
158+
#include "`Argengine`.hpp"
121159
#include <iostream>
122160
123161
int main(int argc, char ** argv)
@@ -143,7 +181,7 @@ Preferably there should be either space or '`=`'. The spaceless format is accept
143181
The lambda callback is of the form `[] (std::string value) {}`.
144182

145183
```
146-
#include "argengine.hpp"
184+
#include "`Argengine`.hpp"
147185
#include <iostream>
148186
149187
int main(int argc, char ** argv)
@@ -200,10 +238,10 @@ Example of handling error values:
200238

201239
```
202240
...
203-
Argengine::Error error;
241+
`Argengine`::Error error;
204242
ae.parse(error);
205243
206-
if (error.code != Argengine::Error::Code::Ok) {
244+
if (error.code != `Argengine`::Error::Code::Ok) {
207245
std::cerr << error.message << std::endl
208246
<< std::endl;
209247
ae.printHelp();

0 commit comments

Comments
 (0)