Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vietjtnguyen committed Apr 26, 2017
1 parent 5e3e792 commit c312777
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ This is yet another C++ command line argument/option parser. It was written as a
- Options and positional arguments can be interleaved
- `--` can be specified to treat all following arguments as positional arguments (i.e. not options)

Help message formatting is provided via the `fmt` utility on {Li,U}nix systems.

[getopt]: https://www.gnu.org/software/libc/manual/html_node/Getopt.html#Getopt
[Boost program options]: http://www.boost.org/doc/libs/release/libs/program_options/
[TCLAP]: http://tclap.sourceforge.net/
Expand Down Expand Up @@ -91,6 +93,17 @@ if (args["help"]) {
}
```

A special output stream, `argagg::fmt_ostream`, is provided that will run the usage and help through `fmt` for nice word wrapping (see [`./examples/joinargs.cpp`](./examples/joinargs.cpp) for a better example).

```cpp
if (args["help"]) {
argagg::fmt_ostream fmt(std::cerr);
fmt << "Usage: program [options] ARG1 ARG2" << std::endl
<< argparser;
return EXIT_SUCCESS;
}
```

Generally `argagg` tries to do a minimal amount of work to leave most of the control with the user.

If you want to get an option argument but fallback on a default value if it doesn't exist then you can use the `argagg::option_results::as()` API and provide a default value.
Expand Down
9 changes: 9 additions & 0 deletions doc/root.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ That help message is only for the flags. If you want a usage message it's up to
return EXIT_SUCCESS;
}

A special output stream, argagg::fmt_ostream, is provided that will run the usage and help through `fmt` for nice word wrapping (see `./examples/joinargs.cpp` for a better example).

if (args["help"]) {
argagg::fmt_ostream fmt(std::cerr);
fmt << "Usage: program [options] ARG1 ARG2" << std::endl
<< argparser;
return EXIT_SUCCESS;
}

Generally argagg tries to do a minimal amount of work to leave most of the control with the user.

If you want to get an option argument but fallback on a default value if it doesn't exist then you can use the argagg::option_results::as() API and provide a default value.
Expand Down

0 comments on commit c312777

Please sign in to comment.