@@ -42,8 +42,8 @@ and instead can write only the help message--*the way you want it*.
42
42
43
43
int main(int argc, const char** argv)
44
44
{
45
- std::map<std::string, docopt::value> args
46
- = docopt::docopt(USAGE,
45
+ std::map<std::string, docopt::value> args
46
+ = docopt::docopt(USAGE,
47
47
{ argv + 1, argv + argc },
48
48
true, // show help if requested
49
49
"Naval Fate 2.0"); // version string
@@ -78,7 +78,10 @@ to work with docopt:
78
78
- GCC 4.9
79
79
- Visual C++ 2015 RC
80
80
81
- Note that GCC-4.8 will not work due to its missing the ``regex `` module.
81
+ GCC-4.8 can work, but the std::regex module needs to be replaced with ``Boost.Regex ``.
82
+ In that case, you will need to define ``DOCTOPT_USE_BOOST_REGEX `` when compiling
83
+ docopt, and link your code with the appropriated Boost libraries. A relativley
84
+ recent version of Boost is needed: 1.55 works, but 1.46 does not for example.
82
85
83
86
This port is licensed under the MIT license, just like the original module.
84
87
However, we are also dual-licensing this code under the Boost License, version 1.0,
@@ -92,8 +95,8 @@ The differences from the Python port are:
92
95
* a ``docopt::value `` type to hold the various value types that can be parsed.
93
96
We considered using boost::variant, but it seems better to have no external
94
97
dependencies (beyond a good STL).
95
- * because C++ is statically-typed and Python is not, we had to make some
96
- changes to the interfaces of the internal parse tree types.
98
+ * because C++ is statically-typed and Python is not, we had to make some
99
+ changes to the interfaces of the internal parse tree types.
97
100
* because ``std::regex `` does not have an equivalent to Python's regex.split,
98
101
some of the regex's had to be restructured and additional loops used.
99
102
126
129
- ``argv `` is a vector of strings representing the args passed. Although
127
130
main usually takes a ``(int argc, const char** argv) `` pair, you can
128
131
pass the value ``{argv+1, argv+argc} `` to generate the vector automatically.
129
- (Note we skip the argv[0] argument!) Alternatively you can supply a list of
132
+ (Note we skip the argv[0] argument!) Alternatively you can supply a list of
130
133
strings like ``{ "--verbose", "-o", "hai.txt" } ``.
131
134
132
135
- ``help ``, by default ``true ``, specifies whether the parser should
155
158
compatibility with POSIX, or if you want to dispatch your arguments
156
159
to other programs.
157
160
158
- The **return ** value is a ``map<string, docopt::value> `` with options,
159
- arguments and commands as keys, spelled exactly like in your help message.
161
+ The **return ** value is a ``map<string, docopt::value> `` with options,
162
+ arguments and commands as keys, spelled exactly like in your help message.
160
163
Long versions of options are given priority. For example, if you invoke the
161
164
top example as::
162
165
@@ -372,7 +375,7 @@ We have an extensive list of `examples
372
375
every aspect of functionality of **docopt **. Try them out, read the
373
376
source if in doubt.
374
377
375
- There are also very intersting applications and ideas at that page.
378
+ There are also very intersting applications and ideas at that page.
376
379
Check out the sister project for more information!
377
380
378
381
Subparsers, multi-level help and *huge * applications (like git)
@@ -397,7 +400,7 @@ a C++ test case runner (run_testcase.cpp)::
397
400
398
401
$ clang++ --std=c++11 --stdlib=libc++ docopt.cpp run_testcase.cpp -o run_testcase
399
402
$ python run_tests.py
400
- PASS (175)
403
+ PASS (175)
401
404
402
405
You can also compile the example shown at the start (included as example.cpp)::
403
406
@@ -424,10 +427,10 @@ You can also compile the example shown at the start (included as example.cpp)::
424
427
Development
425
428
---------------------------------------------------
426
429
427
- Comments and suggestions are *very * welcome! If you find issues, please
430
+ Comments and suggestions are *very * welcome! If you find issues, please
428
431
file them and help improve our code!
429
432
430
- Please note, however, that we have tried to stay true to the original
433
+ Please note, however, that we have tried to stay true to the original
431
434
Python code. If you have any major patches, structural changes, or new features,
432
435
we might want to first negotiate these changes into the Python code first.
433
436
However, bring it up! Let's hear it!
@@ -439,4 +442,3 @@ Changelog
439
442
first release with stable API will be 1.0.0 (soon).
440
443
441
444
- 0.6.1 The initial C++ port of docopt.py
442
-
0 commit comments