Commit 238d9088cc59b056527116fdad0364555c305844

Authored by Henry Fredrick Schreiner
1 parent 3b6def13

Nicer readme after meeting

Showing 1 changed file with 34 additions and 22 deletions
README.md
... ... @@ -3,32 +3,42 @@
3 3 # CLI11
4 4  
5 5 CLI11 provides all the features you expect in a powerful command line parser, with a beautiful, minimal syntax and no dependencies beyond C++11. It is header only, and comes in a single file form for easy inclusion in projects. It is easy to use for small projects, but powerful enough for complex command line projects, and can be customized for frameworks.
6   -It is tested on Travis with a suite of tests, and is being included in the [GooFit GPU fitting framework](https://github.com/GooFit/GooFit). It was inspired by [`plumbum.cli`](http://plumbum.readthedocs.io/en/latest/) for Python.
  6 +It is tested on [Travis with a suite of tests](https://travis-ci.org/henryiii/CLI11), and is being included in the [GooFit GPU fitting framework](https://github.com/GooFit/GooFit). It was inspired by [`plumbum.cli`](http://plumbum.readthedocs.io/en/latest/) for Python. It has both a user friendly introduction here, as well as [API documentation](https://henryiii.github.io/CLI11/index.html) generated by Travis.
7 7  
8 8 ### Why write another CLI parser?
9 9  
10   -The following attributes are what I believe are important in a CLI parser library:
  10 +An acceptable CLI parser library should be all of the following:
11 11  
12 12 * Easy to include (i.e., header only, one file if possible, no external requirements): While many programs depend on Boost, that should not be a requirement if all you want is CLI parsing.
13 13 * Short Syntax: This is one of the main points of a CLI parser, it should make variables from the command line nearly as easy to define as any other variables. If most of your program is hidden in CLI parsing, this is a problem for readability.
14   -* Work with GCC 4.7+ (such as GCC 4.8 on CentOS 7) or above, or Clang 3.5+. (3.4 only fails because of tests, googlemock does not support it.) Works on Linux and MacOS.
  14 +* C++11 or better: Should work with GCC 4.7+ (such as GCC 4.8 on CentOS 7) or above, or Clang 3.5+. (Note: for CLI11, Clang 3.4 only fails because of tests, googlemock does not support it.)
  15 +* Work at least on Linux and MacOS.
15 16 * Well tested using Travis.
16   -* Good help printing (in progress).
17   -* Standard idioms supported naturally, like grouping flags, the positional separator, etc.
  17 +* Clear help printing.
  18 +* Standard shell idioms supported naturally, like grouping flags, a positional separator, etc.
18 19 * Easy to execute, with help, parse errors, etc. providing correct exit and details.
19   -* Easy to extend as part of a framework that provides "applications".
20   -* Human readable support for subcommands.
21   -* Produce real values that can be used directly in code, not something you have pay compute time to look up.
  20 +* Easy to extend as part of a framework that provides "applications" to users.
  21 +* Usable subcommands.
  22 +* Produce real values that can be used directly in code, not something you have pay compute time to look up, for HPC applications.
22 23  
23   -The major CLI parsers out there include:
  24 +The major CLI parsers for C++ include:
24 25  
25   -* [Boost Program Options](http://www.boost.org/doc/libs/1_63_0/doc/html/program_options.html): A great library if you already depend on Boost, its pre-C++11 syntax is really odd and setting up the correct call in the main function is poorly documented. A simple wrapper for the Boost library (Program.hpp) was originally developed, but has been discarded in favor of CLI11.
26   -* [The Lean Mean C++ Option Parser](http://optionparser.sourceforge.net): One header file is great, but the syntax is atrocious, IMO.
27   -* [TCLAP](http://tclap.sourceforge.net): Not quite standard command line parsing, seems to not be well supported anymore. Header only, but in quite a few files. Not even moved to GitHub yet.
28   -* [Cxxopts](https://github.com/jarro2783/cxxopts): C++ 11, single file, and nice CMake support, but requires regex, therefore GCC 4.8 (CentOS 7 default) does not work. Syntax closely based on Boost PO, so not ideal but familiar.
  26 +* [Boost Program Options](http://www.boost.org/doc/libs/1_63_0/doc/html/program_options.html): A great library if you already depend on Boost, but its pre-C++11 syntax is really odd and setting up the correct call in the main function is poorly documented (and is nearly a page of code). A simple wrapper for the Boost library was originally developed, but was discarded as CLI11 became more powerful. The idea of capturing a value and setting it originated with Boost PO.
  27 +* [The Lean Mean C++ Option Parser](http://optionparser.sourceforge.net): One header file is great, but the syntax is atrocious, in my opinion. It was quite impractical to wrap the syntax or to use in a complex project. It seems to handle standard parsing quite well.
  28 +* [TCLAP](http://tclap.sourceforge.net): The not-quite-standard command line parsing causes common shortcuts to fail. It also seems to be poorly supported, with only minimal bugfixes accepted. Header only, but in quite a few files. Has not managed to get enough support to move to GitHub yet. No subcommands. Produced wrapped values.
  29 +* [Cxxopts](https://github.com/jarro2783/cxxopts): C++11, single file, and nice CMake support, but requires regex, therefore GCC 4.8 (CentOS 7 default) does not work. Syntax closely based on Boost PO, so not ideal but familiar.
29 30  
30 31 So, this library was designed to provide a great syntax, good compiler compatibility, and minimal installation fuss.
31 32  
  33 +## Current status:
  34 +
  35 +This library was built to supply the Application object for the GooFit CUDA/OMP fitting library. Before version 2.0 of GooFit is released, this library will reach version 1.0 status. The current tasks still planned are:
  36 +
  37 +* Expand tests to include a few more features
  38 +* Improve documentation
  39 +* Collect user feedback
  40 +* Evaluate compatibility with [ROOT](https://root.cern.ch)'s TApplication object.
  41 +
32 42 ## Installing
33 43  
34 44 To use, there are two methods:
... ... @@ -36,7 +46,7 @@ To use, there are two methods:
36 46 1. Copy `CLI11.hpp` from the [most recent release](https://github.com/henryiii/CLI11/releases) into your include directory, and you are set. This is combined from the source files for every release.
37 47 2. Checkout the repository and add as a subdirectory for CMake. You can use the CLI interface target. (CMake 3.4+ recommended)
38 48  
39   -To build the tests, get the entire directory and use CMake:
  49 +To build the tests, checkout the repository and use CMake:
40 50  
41 51 ```bash
42 52 mkdir build
... ... @@ -67,7 +77,7 @@ The initialization is just one line, adding options is just two each. The try/ca
67 77  
68 78 The supported values are:
69 79  
70   -```
  80 +```cpp
71 81 app.add_options(option_name,
72 82 variable_to_bind_to, // int, float, vector, or string-like
73 83 help_string="",
... ... @@ -92,7 +102,7 @@ App* subcom = app.add_subcommand(name, discription);
92 102  
93 103 ```
94 104  
95   -An option name must start with a alphabetic character or underscore. For long options, anything but an equals sign or a comma is valid after that. Names are given as a comma separated string, with the dash or dashes. An option or flag can have as many names as you want, and afterward, using `count`, you can use any of the names, with dashes as needed, to count the options. One of the names is allowed to be given without proceeding dash(es); if present the option is a positional option, and that name will be used on help line for its positional form.
  105 +An option name must start with a alphabetic character or underscore. For long options, anything but an equals sign or a comma is valid after that. Names are given as a comma separated string, with the dash or dashes. An option or flag can have as many names as you want, and afterward, using `count`, you can use any of the names, with dashes as needed, to count the options. One of the names is allowed to be given without proceeding dash(es); if present the option is a positional option, and that name will be used on help line for its positional form. If you want the default value to print in the help description, pass in `true` for the final parameter for `add_option` or `add_set`.
96 106  
97 107 Adding a configuration option is special. If it is present, it will be read along with the normal command line arguments. The file will be read if it exists, and does not throw an error unless required is `true`.
98 108  
... ... @@ -103,7 +113,7 @@ Adding a configuration option is special. If it is present, it will be read alon
103 113 > * `"-a,-b,-c"` No limit to the number of non-positional option names
104 114  
105 115  
106   -The add commands return a pointer to an internally stored `Option`. If you set the final argument to true, the default value is captured and printed on the command line with the help flag. This option can be used direcly to check for the count (`->count()`) after parsing to avoid a string based lookup. Before parsing, you can set the following options:
  116 +The add commands return a pointer to an internally stored `Option`. If you set the final argument to true, the default value is captured and printed on the command line with the help flag. This option can be used directly to check for the count (`->count()`) after parsing to avoid a string based lookup. Before parsing, you can set the following options:
107 117  
108 118 * `->required()`: The program will quit if this option is not present. This is `mandatory` in Plumbum, but required options seems to be a more standard term. For compatibility, `->mandatory()` also works.
109 119 * `->expected(N)`: Take `N` values instead of as many as possible, only for vector args
... ... @@ -143,17 +153,19 @@ All `App`s have a `get_subcommand()` method, which returns a pointer to the subc
143 153 even exit the program through the callback. The main `App` has a callback slot, as well, but it is generally not as useful.
144 154  
145 155  
146   -
147 156 ## Subclassing
148 157  
149   -The App class was designed allow toolkits to subclass it, to provide default options and setup/teardown code. Subcommands remain `App`'s, since those are not expected to need setup and teardown. The default `App` only adds a help flag, `-h,--help`, but provides an option to disable it in the constructor (and in `add_subcommand`).
  158 +The App class was designed allow toolkits to subclass it, to provide default options and setup/teardown code. Subcommands remain an unsubclassed `App`, since those are not expected to need setup and teardown. The default `App` only adds a help flag, `-h,--help`, but provides an option to disable it in the constructor (and in `add_subcommand`).
150 159  
151   -Also, in a related note, the `App`s you get a pointer to are stored in the parent `App` in `unique_ptr`s (like `Option`s) and are deleted when the main `App` goes out of scope.
  160 +Also, in a related note, the `App` you get a pointer to is stored in the parent `App` in a `unique_ptr`s (like `Option`s) and are deleted when the main `App` goes out of scope.
152 161  
153 162  
154 163 ## How it works
155 164  
156   -Every `add_` option you've seen depends on one method that takes a lambda function. Each of these methods is just making a different lambda function with capture to populate the option. The function has full access to the vector of vector of strings, so it knows how many times an option was passed, and how many arguments each passing received (flags add empty strings to keep the counts correct). The lambda returns true if it could validate the option strings, and
157   -false if it failed.
  165 +Every `add_` option you have seen so far depends on one method that takes a lambda function. Each of these methods is just making a different lambda function with capture to populate the option. The function has full access to the vector of vector of strings, so it knows how many times an option was passed, and how many arguments each passing received (flags add empty strings to keep the counts correct). The lambda returns `true` if it could validate the option strings, and
  166 +`false` if it failed.
  167 +
  168 +## Contributing
158 169  
  170 +To contribute, open an issue or pull request on GitHub.
159 171  
... ...