couchbase 4.2.1 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/CMakeLists.txt +1 -0
  2. package/deps/couchbase-cxx-client/.gitmodules +3 -0
  3. package/deps/couchbase-cxx-client/.idea/misc.xml +1 -0
  4. package/deps/couchbase-cxx-client/.idea/vcs.xml +1 -0
  5. package/deps/couchbase-cxx-client/CMakeLists.txt +11 -1
  6. package/deps/couchbase-cxx-client/README.md +3 -3
  7. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +4 -1
  8. package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +13 -1
  9. package/deps/couchbase-cxx-client/cmake/build_version.hxx.in +1 -0
  10. package/deps/couchbase-cxx-client/core/cluster.hxx +15 -5
  11. package/deps/couchbase-cxx-client/core/impl/build_deferred_query_indexes.cxx +17 -6
  12. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -1
  13. package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +93 -0
  14. package/deps/couchbase-cxx-client/core/impl/configuration_profiles_registry.cxx +11 -0
  15. package/deps/couchbase-cxx-client/core/impl/create_query_index.cxx +119 -0
  16. package/deps/couchbase-cxx-client/core/impl/drop_query_index.cxx +108 -0
  17. package/deps/couchbase-cxx-client/core/impl/get.cxx +1 -1
  18. package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +76 -0
  19. package/deps/couchbase-cxx-client/core/impl/query.cxx +5 -7
  20. package/deps/couchbase-cxx-client/core/impl/watch_query_indexes.cxx +168 -0
  21. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +15 -1
  22. package/deps/couchbase-cxx-client/core/logger/configuration.hxx +3 -0
  23. package/deps/couchbase-cxx-client/core/logger/level.hxx +21 -0
  24. package/deps/couchbase-cxx-client/core/logger/logger.hxx +4 -6
  25. package/deps/couchbase-cxx-client/core/meta/CMakeLists.txt +4 -2
  26. package/deps/couchbase-cxx-client/core/meta/features.hxx +31 -0
  27. package/deps/couchbase-cxx-client/core/meta/version.cxx +67 -5
  28. package/deps/couchbase-cxx-client/core/meta/version.hxx +12 -1
  29. package/deps/couchbase-cxx-client/core/metrics/CMakeLists.txt +4 -1
  30. package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +46 -5
  31. package/deps/couchbase-cxx-client/core/metrics/logging_meter.hxx +10 -26
  32. package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -2
  33. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +10 -12
  34. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +1 -3
  35. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.cxx +8 -14
  36. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -1
  37. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +15 -8
  38. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +7 -14
  39. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
  40. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +11 -16
  41. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
  42. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.cxx +8 -12
  43. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
  44. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.cxx +21 -12
  45. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +3 -2
  46. package/deps/couchbase-cxx-client/core/origin.hxx +1 -1
  47. package/deps/couchbase-cxx-client/core/platform/uuid.cc +1 -2
  48. package/deps/couchbase-cxx-client/core/protocol/cmd_hello.hxx +5 -1
  49. package/deps/couchbase-cxx-client/core/query_context.hxx +79 -0
  50. package/deps/couchbase-cxx-client/core/tracing/CMakeLists.txt +3 -1
  51. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +19 -4
  52. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.hxx +2 -2
  53. package/deps/couchbase-cxx-client/core/transactions/async_attempt_context.hxx +10 -4
  54. package/deps/couchbase-cxx-client/core/transactions/atr_cleanup_entry.cxx +52 -63
  55. package/deps/couchbase-cxx-client/core/transactions/attempt_context.hxx +8 -3
  56. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +163 -126
  57. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +24 -37
  58. package/deps/couchbase-cxx-client/core/transactions/forward_compat.hxx +4 -4
  59. package/deps/couchbase-cxx-client/core/transactions/internal/atr_cleanup_entry.hxx +51 -13
  60. package/deps/couchbase-cxx-client/core/transactions/internal/client_record.hxx +26 -1
  61. package/deps/couchbase-cxx-client/core/transactions/internal/doc_record.hxx +21 -0
  62. package/deps/couchbase-cxx-client/core/transactions/internal/logging.hxx +40 -18
  63. package/deps/couchbase-cxx-client/core/transactions/internal/transaction_context.hxx +5 -0
  64. package/deps/couchbase-cxx-client/core/transactions/result.hxx +26 -0
  65. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +48 -47
  66. package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +6 -6
  67. package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +33 -19
  68. package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +18 -2
  69. package/deps/couchbase-cxx-client/core/transactions/transaction_links.hxx +25 -2
  70. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +4 -4
  71. package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +49 -56
  72. package/deps/couchbase-cxx-client/core/transactions/waitable_op_list.hxx +7 -7
  73. package/deps/couchbase-cxx-client/core/transactions.hxx +0 -12
  74. package/deps/couchbase-cxx-client/core/utils/binary.hxx +1 -1
  75. package/deps/couchbase-cxx-client/core/utils/keyspace.hxx +55 -0
  76. package/deps/couchbase-cxx-client/couchbase/build_query_index_options.hxx +12 -45
  77. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +1 -1
  78. package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +6 -7
  79. package/deps/couchbase-cxx-client/couchbase/collection.hxx +8 -0
  80. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +218 -0
  81. package/deps/couchbase-cxx-client/couchbase/configuration_profiles_registry.hxx +3 -0
  82. package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +166 -0
  83. package/deps/couchbase-cxx-client/couchbase/create_query_index_options.hxx +172 -0
  84. package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +129 -0
  85. package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +116 -0
  86. package/deps/couchbase-cxx-client/couchbase/fmt/cas.hxx +1 -1
  87. package/deps/couchbase-cxx-client/couchbase/fmt/query_scan_consistency.hxx +46 -0
  88. package/deps/couchbase-cxx-client/couchbase/fmt/query_status.hxx +70 -0
  89. package/deps/couchbase-cxx-client/couchbase/fmt/tls_verify_mode.hxx +46 -0
  90. package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +100 -0
  91. package/deps/couchbase-cxx-client/{core → couchbase}/management/query_index.hxx +2 -2
  92. package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +16 -0
  93. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +178 -6
  94. package/deps/couchbase-cxx-client/couchbase/query_options.hxx +1 -18
  95. package/deps/couchbase-cxx-client/couchbase/scope.hxx +5 -2
  96. package/deps/couchbase-cxx-client/couchbase/tracing/request_tracer.hxx +16 -0
  97. package/deps/couchbase-cxx-client/couchbase/transactions/async_attempt_context.hxx +11 -4
  98. package/deps/couchbase-cxx-client/couchbase/transactions/attempt_context.hxx +5 -3
  99. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_keyspace.hxx +16 -0
  100. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +0 -6
  101. package/deps/couchbase-cxx-client/couchbase/watch_query_indexes_options.hxx +115 -0
  102. package/deps/couchbase-cxx-client/examples/minimal.cxx +3 -1
  103. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +72 -0
  104. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +727 -310
  105. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +4 -8
  106. package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +14 -0
  107. package/deps/couchbase-cxx-client/test/test_transaction_transaction_public_blocking_api.cxx +34 -19
  108. package/deps/couchbase-cxx-client/test/test_unit_transaction_logging.cxx +66 -22
  109. package/deps/couchbase-cxx-client/test/test_unit_utils.cxx +51 -0
  110. package/deps/couchbase-cxx-client/test/tools/tool_kv_loader.cxx +2 -2
  111. package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -0
  112. package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +4 -4
  113. package/deps/couchbase-cxx-client/third_party/docopt/.travis.yml +103 -0
  114. package/deps/couchbase-cxx-client/third_party/docopt/CMakeLists.txt +129 -0
  115. package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-Boost-1.0 +23 -0
  116. package/deps/couchbase-cxx-client/third_party/docopt/LICENSE-MIT +23 -0
  117. package/deps/couchbase-cxx-client/third_party/docopt/README.rst +479 -0
  118. package/deps/couchbase-cxx-client/third_party/docopt/docopt-config.cmake +1 -0
  119. package/deps/couchbase-cxx-client/third_party/docopt/docopt.cpp +687 -0
  120. package/deps/couchbase-cxx-client/third_party/docopt/docopt.h +98 -0
  121. package/deps/couchbase-cxx-client/third_party/docopt/docopt.pc.in +9 -0
  122. package/deps/couchbase-cxx-client/third_party/docopt/docopt_private.h +676 -0
  123. package/deps/couchbase-cxx-client/third_party/docopt/docopt_util.h +122 -0
  124. package/deps/couchbase-cxx-client/third_party/docopt/docopt_value.h +341 -0
  125. package/deps/couchbase-cxx-client/third_party/docopt/examples/naval_fate.cpp +36 -0
  126. package/deps/couchbase-cxx-client/third_party/docopt/main.cpp +16 -0
  127. package/deps/couchbase-cxx-client/third_party/docopt/run_testcase.cpp +40 -0
  128. package/deps/couchbase-cxx-client/third_party/docopt/run_tests.py +72 -0
  129. package/deps/couchbase-cxx-client/third_party/docopt/testcases.docopt +957 -0
  130. package/deps/couchbase-cxx-client/tools/CMakeLists.txt +14 -0
  131. package/deps/couchbase-cxx-client/tools/cbc.cxx +65 -0
  132. package/deps/couchbase-cxx-client/tools/command.hxx +31 -0
  133. package/deps/couchbase-cxx-client/tools/command_registry.cxx +43 -0
  134. package/deps/couchbase-cxx-client/tools/command_registry.hxx +39 -0
  135. package/deps/couchbase-cxx-client/tools/get.cxx +267 -0
  136. package/deps/couchbase-cxx-client/tools/get.hxx +26 -0
  137. package/deps/couchbase-cxx-client/tools/query.cxx +441 -0
  138. package/deps/couchbase-cxx-client/tools/query.hxx +26 -0
  139. package/deps/couchbase-cxx-client/tools/utils.cxx +418 -0
  140. package/deps/couchbase-cxx-client/tools/utils.hxx +150 -0
  141. package/deps/couchbase-cxx-client/tools/version.cxx +82 -0
  142. package/deps/couchbase-cxx-client/tools/version.hxx +26 -0
  143. package/dist/authenticators.d.ts +2 -2
  144. package/dist/authenticators.js +1 -2
  145. package/dist/binding.d.ts +32 -16
  146. package/dist/cluster.js +14 -7
  147. package/dist/collection.d.ts +6 -0
  148. package/dist/collection.js +8 -0
  149. package/dist/queryexecutor.js +1 -1
  150. package/dist/queryindexmanager.d.ts +100 -4
  151. package/dist/queryindexmanager.js +344 -118
  152. package/dist/transactions.js +0 -2
  153. package/package.json +1 -1
  154. package/src/connection.cpp +2 -0
  155. package/src/connection.hpp +1 -0
  156. package/src/connection_autogen.cpp +16 -0
  157. package/src/jstocbpp_autogen.hpp +93 -23
  158. package/src/jstocbpp_basic.hpp +24 -0
  159. package/src/jstocbpp_transactions.hpp +0 -8
  160. package/tools/gen-bindings-js.js +1 -0
  161. package/tools/gen-bindings-json.py +4 -2
  162. package/deps/couchbase-cxx-client/core/transactions/logging.cxx +0 -107
@@ -0,0 +1,957 @@
1
+ r"""Usage: prog
2
+
3
+ """
4
+ $ prog
5
+ {}
6
+
7
+ $ prog --xxx
8
+ "user-error"
9
+
10
+
11
+ r"""Usage: prog [options]
12
+
13
+ Options: -a All.
14
+
15
+ """
16
+ $ prog
17
+ {"-a": false}
18
+
19
+ $ prog -a
20
+ {"-a": true}
21
+
22
+ $ prog -x
23
+ "user-error"
24
+
25
+
26
+ r"""Usage: prog [options]
27
+
28
+ Options: --all All.
29
+
30
+ """
31
+ $ prog
32
+ {"--all": false}
33
+
34
+ $ prog --all
35
+ {"--all": true}
36
+
37
+ $ prog --xxx
38
+ "user-error"
39
+
40
+
41
+ r"""Usage: prog [options]
42
+
43
+ Options: -v, --verbose Verbose.
44
+
45
+ """
46
+ $ prog --verbose
47
+ {"--verbose": true}
48
+
49
+ $ prog --ver
50
+ {"--verbose": true}
51
+
52
+ $ prog -v
53
+ {"--verbose": true}
54
+
55
+
56
+ r"""Usage: prog [options]
57
+
58
+ Options: -p PATH
59
+
60
+ """
61
+ $ prog -p home/
62
+ {"-p": "home/"}
63
+
64
+ $ prog -phome/
65
+ {"-p": "home/"}
66
+
67
+ $ prog -p
68
+ "user-error"
69
+
70
+
71
+ r"""Usage: prog [options]
72
+
73
+ Options: --path <path>
74
+
75
+ """
76
+ $ prog --path home/
77
+ {"--path": "home/"}
78
+
79
+ $ prog --path=home/
80
+ {"--path": "home/"}
81
+
82
+ $ prog --pa home/
83
+ {"--path": "home/"}
84
+
85
+ $ prog --pa=home/
86
+ {"--path": "home/"}
87
+
88
+ $ prog --path
89
+ "user-error"
90
+
91
+
92
+ r"""Usage: prog [options]
93
+
94
+ Options: -p PATH, --path=<path> Path to files.
95
+
96
+ """
97
+ $ prog -proot
98
+ {"--path": "root"}
99
+
100
+
101
+ r"""Usage: prog [options]
102
+
103
+ Options: -p --path PATH Path to files.
104
+
105
+ """
106
+ $ prog -p root
107
+ {"--path": "root"}
108
+
109
+ $ prog --path root
110
+ {"--path": "root"}
111
+
112
+
113
+ r"""Usage: prog [options]
114
+
115
+ Options:
116
+ -p PATH Path to files [default: ./]
117
+
118
+ """
119
+ $ prog
120
+ {"-p": "./"}
121
+
122
+ $ prog -phome
123
+ {"-p": "home"}
124
+
125
+
126
+ r"""UsAgE: prog [options]
127
+
128
+ OpTiOnS: --path=<files> Path to files
129
+ [dEfAuLt: /root]
130
+
131
+ """
132
+ $ prog
133
+ {"--path": "/root"}
134
+
135
+ $ prog --path=home
136
+ {"--path": "home"}
137
+
138
+
139
+ r"""usage: prog [options]
140
+
141
+ options:
142
+ -a Add
143
+ -r Remote
144
+ -m <msg> Message
145
+
146
+ """
147
+ $ prog -a -r -m Hello
148
+ {"-a": true,
149
+ "-r": true,
150
+ "-m": "Hello"}
151
+
152
+ $ prog -armyourass
153
+ {"-a": true,
154
+ "-r": true,
155
+ "-m": "yourass"}
156
+
157
+ $ prog -a -r
158
+ {"-a": true,
159
+ "-r": true,
160
+ "-m": null}
161
+
162
+
163
+ r"""Usage: prog [options]
164
+
165
+ Options: --version
166
+ --verbose
167
+
168
+ """
169
+ $ prog --version
170
+ {"--version": true,
171
+ "--verbose": false}
172
+
173
+ $ prog --verbose
174
+ {"--version": false,
175
+ "--verbose": true}
176
+
177
+ $ prog --ver
178
+ "user-error"
179
+
180
+ $ prog --verb
181
+ {"--version": false,
182
+ "--verbose": true}
183
+
184
+
185
+ r"""usage: prog [-a -r -m <msg>]
186
+
187
+ options:
188
+ -a Add
189
+ -r Remote
190
+ -m <msg> Message
191
+
192
+ """
193
+ $ prog -armyourass
194
+ {"-a": true,
195
+ "-r": true,
196
+ "-m": "yourass"}
197
+
198
+
199
+ r"""usage: prog [-armmsg]
200
+
201
+ options: -a Add
202
+ -r Remote
203
+ -m <msg> Message
204
+
205
+ """
206
+ $ prog -a -r -m Hello
207
+ {"-a": true,
208
+ "-r": true,
209
+ "-m": "Hello"}
210
+
211
+
212
+ r"""usage: prog -a -b
213
+
214
+ options:
215
+ -a
216
+ -b
217
+
218
+ """
219
+ $ prog -a -b
220
+ {"-a": true, "-b": true}
221
+
222
+ $ prog -b -a
223
+ {"-a": true, "-b": true}
224
+
225
+ $ prog -a
226
+ "user-error"
227
+
228
+ $ prog
229
+ "user-error"
230
+
231
+
232
+ r"""usage: prog (-a -b)
233
+
234
+ options: -a
235
+ -b
236
+
237
+ """
238
+ $ prog -a -b
239
+ {"-a": true, "-b": true}
240
+
241
+ $ prog -b -a
242
+ {"-a": true, "-b": true}
243
+
244
+ $ prog -a
245
+ "user-error"
246
+
247
+ $ prog
248
+ "user-error"
249
+
250
+
251
+ r"""usage: prog [-a] -b
252
+
253
+ options: -a
254
+ -b
255
+
256
+ """
257
+ $ prog -a -b
258
+ {"-a": true, "-b": true}
259
+
260
+ $ prog -b -a
261
+ {"-a": true, "-b": true}
262
+
263
+ $ prog -a
264
+ "user-error"
265
+
266
+ $ prog -b
267
+ {"-a": false, "-b": true}
268
+
269
+ $ prog
270
+ "user-error"
271
+
272
+
273
+ r"""usage: prog [(-a -b)]
274
+
275
+ options: -a
276
+ -b
277
+
278
+ """
279
+ $ prog -a -b
280
+ {"-a": true, "-b": true}
281
+
282
+ $ prog -b -a
283
+ {"-a": true, "-b": true}
284
+
285
+ $ prog -a
286
+ "user-error"
287
+
288
+ $ prog -b
289
+ "user-error"
290
+
291
+ $ prog
292
+ {"-a": false, "-b": false}
293
+
294
+
295
+ r"""usage: prog (-a|-b)
296
+
297
+ options: -a
298
+ -b
299
+
300
+ """
301
+ $ prog -a -b
302
+ "user-error"
303
+
304
+ $ prog
305
+ "user-error"
306
+
307
+ $ prog -a
308
+ {"-a": true, "-b": false}
309
+
310
+ $ prog -b
311
+ {"-a": false, "-b": true}
312
+
313
+
314
+ r"""usage: prog [ -a | -b ]
315
+
316
+ options: -a
317
+ -b
318
+
319
+ """
320
+ $ prog -a -b
321
+ "user-error"
322
+
323
+ $ prog
324
+ {"-a": false, "-b": false}
325
+
326
+ $ prog -a
327
+ {"-a": true, "-b": false}
328
+
329
+ $ prog -b
330
+ {"-a": false, "-b": true}
331
+
332
+
333
+ r"""usage: prog <arg>"""
334
+ $ prog 10
335
+ {"<arg>": "10"}
336
+
337
+ $ prog 10 20
338
+ "user-error"
339
+
340
+ $ prog
341
+ "user-error"
342
+
343
+
344
+ r"""usage: prog [<arg>]"""
345
+ $ prog 10
346
+ {"<arg>": "10"}
347
+
348
+ $ prog 10 20
349
+ "user-error"
350
+
351
+ $ prog
352
+ {"<arg>": null}
353
+
354
+
355
+ r"""usage: prog <kind> <name> <type>"""
356
+ $ prog 10 20 40
357
+ {"<kind>": "10", "<name>": "20", "<type>": "40"}
358
+
359
+ $ prog 10 20
360
+ "user-error"
361
+
362
+ $ prog
363
+ "user-error"
364
+
365
+
366
+ r"""usage: prog <kind> [<name> <type>]"""
367
+ $ prog 10 20 40
368
+ {"<kind>": "10", "<name>": "20", "<type>": "40"}
369
+
370
+ $ prog 10 20
371
+ {"<kind>": "10", "<name>": "20", "<type>": null}
372
+
373
+ $ prog
374
+ "user-error"
375
+
376
+
377
+ r"""usage: prog [<kind> | <name> <type>]"""
378
+ $ prog 10 20 40
379
+ "user-error"
380
+
381
+ $ prog 20 40
382
+ {"<kind>": null, "<name>": "20", "<type>": "40"}
383
+
384
+ $ prog
385
+ {"<kind>": null, "<name>": null, "<type>": null}
386
+
387
+
388
+ r"""usage: prog (<kind> --all | <name>)
389
+
390
+ options:
391
+ --all
392
+
393
+ """
394
+ $ prog 10 --all
395
+ {"<kind>": "10", "--all": true, "<name>": null}
396
+
397
+ $ prog 10
398
+ {"<kind>": null, "--all": false, "<name>": "10"}
399
+
400
+ $ prog
401
+ "user-error"
402
+
403
+
404
+ r"""usage: prog [<name> <name>]"""
405
+ $ prog 10 20
406
+ {"<name>": ["10", "20"]}
407
+
408
+ $ prog 10
409
+ {"<name>": ["10"]}
410
+
411
+ $ prog
412
+ {"<name>": []}
413
+
414
+
415
+ r"""usage: prog [(<name> <name>)]"""
416
+ $ prog 10 20
417
+ {"<name>": ["10", "20"]}
418
+
419
+ $ prog 10
420
+ "user-error"
421
+
422
+ $ prog
423
+ {"<name>": []}
424
+
425
+
426
+ r"""usage: prog NAME..."""
427
+ $ prog 10 20
428
+ {"NAME": ["10", "20"]}
429
+
430
+ $ prog 10
431
+ {"NAME": ["10"]}
432
+
433
+ $ prog
434
+ "user-error"
435
+
436
+
437
+ r"""usage: prog [NAME]..."""
438
+ $ prog 10 20
439
+ {"NAME": ["10", "20"]}
440
+
441
+ $ prog 10
442
+ {"NAME": ["10"]}
443
+
444
+ $ prog
445
+ {"NAME": []}
446
+
447
+
448
+ r"""usage: prog [NAME...]"""
449
+ $ prog 10 20
450
+ {"NAME": ["10", "20"]}
451
+
452
+ $ prog 10
453
+ {"NAME": ["10"]}
454
+
455
+ $ prog
456
+ {"NAME": []}
457
+
458
+
459
+ r"""usage: prog [NAME [NAME ...]]"""
460
+ $ prog 10 20
461
+ {"NAME": ["10", "20"]}
462
+
463
+ $ prog 10
464
+ {"NAME": ["10"]}
465
+
466
+ $ prog
467
+ {"NAME": []}
468
+
469
+
470
+ r"""usage: prog (NAME | --foo NAME)
471
+
472
+ options: --foo
473
+
474
+ """
475
+ $ prog 10
476
+ {"NAME": "10", "--foo": false}
477
+
478
+ $ prog --foo 10
479
+ {"NAME": "10", "--foo": true}
480
+
481
+ $ prog --foo=10
482
+ "user-error"
483
+
484
+
485
+ r"""usage: prog (NAME | --foo) [--bar | NAME]
486
+
487
+ options: --foo
488
+ options: --bar
489
+
490
+ """
491
+ $ prog 10
492
+ {"NAME": ["10"], "--foo": false, "--bar": false}
493
+
494
+ $ prog 10 20
495
+ {"NAME": ["10", "20"], "--foo": false, "--bar": false}
496
+
497
+ $ prog --foo --bar
498
+ {"NAME": [], "--foo": true, "--bar": true}
499
+
500
+
501
+ r"""Naval Fate.
502
+
503
+ Usage:
504
+ prog ship new <name>...
505
+ prog ship [<name>] move <x> <y> [--speed=<kn>]
506
+ prog ship shoot <x> <y>
507
+ prog mine (set|remove) <x> <y> [--moored|--drifting]
508
+ prog -h | --help
509
+ prog --version
510
+
511
+ Options:
512
+ -h --help Show this screen.
513
+ --version Show version.
514
+ --speed=<kn> Speed in knots [default: 10].
515
+ --moored Mored (anchored) mine.
516
+ --drifting Drifting mine.
517
+
518
+ """
519
+ $ prog ship Guardian move 150 300 --speed=20
520
+ {"--drifting": false,
521
+ "--help": false,
522
+ "--moored": false,
523
+ "--speed": "20",
524
+ "--version": false,
525
+ "<name>": ["Guardian"],
526
+ "<x>": "150",
527
+ "<y>": "300",
528
+ "mine": false,
529
+ "move": true,
530
+ "new": false,
531
+ "remove": false,
532
+ "set": false,
533
+ "ship": true,
534
+ "shoot": false}
535
+
536
+
537
+ r"""usage: prog --hello"""
538
+ $ prog --hello
539
+ {"--hello": true}
540
+
541
+
542
+ r"""usage: prog [--hello=<world>]"""
543
+ $ prog
544
+ {"--hello": null}
545
+
546
+ $ prog --hello wrld
547
+ {"--hello": "wrld"}
548
+
549
+
550
+ r"""usage: prog [-o]"""
551
+ $ prog
552
+ {"-o": false}
553
+
554
+ $ prog -o
555
+ {"-o": true}
556
+
557
+
558
+ r"""usage: prog [-opr]"""
559
+ $ prog -op
560
+ {"-o": true, "-p": true, "-r": false}
561
+
562
+
563
+ r"""usage: prog --aabb | --aa"""
564
+ $ prog --aa
565
+ {"--aabb": false, "--aa": true}
566
+
567
+ $ prog --a
568
+ "user-error" # not a unique prefix
569
+
570
+ #
571
+ # Counting number of flags
572
+ #
573
+
574
+ r"""Usage: prog -v"""
575
+ $ prog -v
576
+ {"-v": true}
577
+
578
+
579
+ r"""Usage: prog [-v -v]"""
580
+ $ prog
581
+ {"-v": 0}
582
+
583
+ $ prog -v
584
+ {"-v": 1}
585
+
586
+ $ prog -vv
587
+ {"-v": 2}
588
+
589
+
590
+ r"""Usage: prog -v ..."""
591
+ $ prog
592
+ "user-error"
593
+
594
+ $ prog -v
595
+ {"-v": 1}
596
+
597
+ $ prog -vv
598
+ {"-v": 2}
599
+
600
+ $ prog -vvvvvv
601
+ {"-v": 6}
602
+
603
+
604
+ r"""Usage: prog [-v | -vv | -vvv]
605
+
606
+ This one is probably most readable user-friednly variant.
607
+
608
+ """
609
+ $ prog
610
+ {"-v": 0}
611
+
612
+ $ prog -v
613
+ {"-v": 1}
614
+
615
+ $ prog -vv
616
+ {"-v": 2}
617
+
618
+ $ prog -vvvv
619
+ "user-error"
620
+
621
+
622
+ r"""usage: prog [--ver --ver]"""
623
+ $ prog --ver --ver
624
+ {"--ver": 2}
625
+
626
+
627
+ #
628
+ # Counting commands
629
+ #
630
+
631
+ r"""usage: prog [go]"""
632
+ $ prog go
633
+ {"go": true}
634
+
635
+
636
+ r"""usage: prog [go go]"""
637
+ $ prog
638
+ {"go": 0}
639
+
640
+ $ prog go
641
+ {"go": 1}
642
+
643
+ $ prog go go
644
+ {"go": 2}
645
+
646
+ $ prog go go go
647
+ "user-error"
648
+
649
+ r"""usage: prog go..."""
650
+ $ prog go go go go go
651
+ {"go": 5}
652
+
653
+ #
654
+ # [options] does not include options from usage-pattern
655
+ #
656
+ r"""usage: prog [options] [-a]
657
+
658
+ options: -a
659
+ -b
660
+ """
661
+ $ prog -a
662
+ {"-a": true, "-b": false}
663
+
664
+ $ prog -aa
665
+ "user-error"
666
+
667
+ #
668
+ # Test [options] shourtcut
669
+ #
670
+
671
+ r"""Usage: prog [options] A
672
+ Options:
673
+ -q Be quiet
674
+ -v Be verbose.
675
+
676
+ """
677
+ $ prog arg
678
+ {"A": "arg", "-v": false, "-q": false}
679
+
680
+ $ prog -v arg
681
+ {"A": "arg", "-v": true, "-q": false}
682
+
683
+ $ prog -q arg
684
+ {"A": "arg", "-v": false, "-q": true}
685
+
686
+ #
687
+ # Test single dash
688
+ #
689
+
690
+ r"""usage: prog [-]"""
691
+
692
+ $ prog -
693
+ {"-": true}
694
+
695
+ $ prog
696
+ {"-": false}
697
+
698
+ #
699
+ # If argument is repeated, its value should always be a list
700
+ #
701
+
702
+ r"""usage: prog [NAME [NAME ...]]"""
703
+
704
+ $ prog a b
705
+ {"NAME": ["a", "b"]}
706
+
707
+ $ prog
708
+ {"NAME": []}
709
+
710
+ #
711
+ # Option's argument defaults to null/None
712
+ #
713
+
714
+ r"""usage: prog [options]
715
+ options:
716
+ -a Add
717
+ -m <msg> Message
718
+
719
+ """
720
+ $ prog -a
721
+ {"-m": null, "-a": true}
722
+
723
+ #
724
+ # Test options without description
725
+ #
726
+
727
+ r"""usage: prog --hello"""
728
+ $ prog --hello
729
+ {"--hello": true}
730
+
731
+ r"""usage: prog [--hello=<world>]"""
732
+ $ prog
733
+ {"--hello": null}
734
+
735
+ $ prog --hello wrld
736
+ {"--hello": "wrld"}
737
+
738
+ r"""usage: prog [-o]"""
739
+ $ prog
740
+ {"-o": false}
741
+
742
+ $ prog -o
743
+ {"-o": true}
744
+
745
+ r"""usage: prog [-opr]"""
746
+ $ prog -op
747
+ {"-o": true, "-p": true, "-r": false}
748
+
749
+ r"""usage: git [-v | --verbose]"""
750
+ $ prog -v
751
+ {"-v": true, "--verbose": false}
752
+
753
+ r"""usage: git remote [-v | --verbose]"""
754
+ $ prog remote -v
755
+ {"remote": true, "-v": true, "--verbose": false}
756
+
757
+ #
758
+ # Test empty usage pattern
759
+ #
760
+
761
+ r"""usage: prog"""
762
+ $ prog
763
+ {}
764
+
765
+ r"""usage: prog
766
+ prog <a> <b>
767
+ """
768
+ $ prog 1 2
769
+ {"<a>": "1", "<b>": "2"}
770
+
771
+ $ prog
772
+ {"<a>": null, "<b>": null}
773
+
774
+ r"""usage: prog <a> <b>
775
+ prog
776
+ """
777
+ $ prog
778
+ {"<a>": null, "<b>": null}
779
+
780
+ #
781
+ # Option's argument should not capture default value from usage pattern
782
+ #
783
+
784
+ r"""usage: prog [--file=<f>]"""
785
+ $ prog
786
+ {"--file": null}
787
+
788
+ r"""usage: prog [--file=<f>]
789
+
790
+ options: --file <a>
791
+
792
+ """
793
+ $ prog
794
+ {"--file": null}
795
+
796
+ r"""Usage: prog [-a <host:port>]
797
+
798
+ Options: -a, --address <host:port> TCP address [default: localhost:6283].
799
+
800
+ """
801
+ $ prog
802
+ {"--address": "localhost:6283"}
803
+
804
+ #
805
+ # If option with argument could be repeated,
806
+ # its arguments should be accumulated into a list
807
+ #
808
+
809
+ r"""usage: prog --long=<arg> ..."""
810
+
811
+ $ prog --long one
812
+ {"--long": ["one"]}
813
+
814
+ $ prog --long one --long two
815
+ {"--long": ["one", "two"]}
816
+
817
+ #
818
+ # Test multiple elements repeated at once
819
+ #
820
+
821
+ r"""usage: prog (go <direction> --speed=<km/h>)..."""
822
+ $ prog go left --speed=5 go right --speed=9
823
+ {"go": 2, "<direction>": ["left", "right"], "--speed": ["5", "9"]}
824
+
825
+ #
826
+ # Required options should work with option shortcut
827
+ #
828
+
829
+ r"""usage: prog [options] -a
830
+
831
+ options: -a
832
+
833
+ """
834
+ $ prog -a
835
+ {"-a": true}
836
+
837
+ #
838
+ # If option could be repeated its defaults should be split into a list
839
+ #
840
+
841
+ r"""usage: prog [-o <o>]...
842
+
843
+ options: -o <o> [default: x]
844
+
845
+ """
846
+ $ prog -o this -o that
847
+ {"-o": ["this", "that"]}
848
+
849
+ $ prog
850
+ {"-o": ["x"]}
851
+
852
+ r"""usage: prog [-o <o>]...
853
+
854
+ options: -o <o> [default: x y]
855
+
856
+ """
857
+ $ prog -o this
858
+ {"-o": ["this"]}
859
+
860
+ $ prog
861
+ {"-o": ["x", "y"]}
862
+
863
+ #
864
+ # Test stacked option's argument
865
+ #
866
+
867
+ r"""usage: prog -pPATH
868
+
869
+ options: -p PATH
870
+
871
+ """
872
+ $ prog -pHOME
873
+ {"-p": "HOME"}
874
+
875
+ #
876
+ # Issue 56: Repeated mutually exclusive args give nested lists sometimes
877
+ #
878
+
879
+ r"""Usage: foo (--xx=x|--yy=y)..."""
880
+ $ prog --xx=1 --yy=2
881
+ {"--xx": ["1"], "--yy": ["2"]}
882
+
883
+ #
884
+ # POSIXly correct tokenization
885
+ #
886
+
887
+ r"""usage: prog [<input file>]"""
888
+ $ prog f.txt
889
+ {"<input file>": "f.txt"}
890
+
891
+ r"""usage: prog [--input=<file name>]..."""
892
+ $ prog --input a.txt --input=b.txt
893
+ {"--input": ["a.txt", "b.txt"]}
894
+
895
+ #
896
+ # Issue 85: `[options]` shourtcut with multiple subcommands
897
+ #
898
+
899
+ r"""usage: prog good [options]
900
+ prog fail [options]
901
+
902
+ options: --loglevel=N
903
+
904
+ """
905
+ $ prog fail --loglevel 5
906
+ {"--loglevel": "5", "fail": true, "good": false}
907
+
908
+ #
909
+ # Usage-section syntax
910
+ #
911
+
912
+ r"""usage:prog --foo"""
913
+ $ prog --foo
914
+ {"--foo": true}
915
+
916
+ r"""PROGRAM USAGE: prog --foo"""
917
+ $ prog --foo
918
+ {"--foo": true}
919
+
920
+ r"""Usage: prog --foo
921
+ prog --bar
922
+ NOT PART OF SECTION"""
923
+ $ prog --foo
924
+ {"--foo": true, "--bar": false}
925
+
926
+ r"""Usage:
927
+ prog --foo
928
+ prog --bar
929
+
930
+ NOT PART OF SECTION"""
931
+ $ prog --foo
932
+ {"--foo": true, "--bar": false}
933
+
934
+ r"""Usage:
935
+ prog --foo
936
+ prog --bar
937
+ NOT PART OF SECTION"""
938
+ $ prog --foo
939
+ {"--foo": true, "--bar": false}
940
+
941
+ #
942
+ # Options-section syntax
943
+ #
944
+
945
+ r"""Usage: prog [options]
946
+
947
+ global options: --foo
948
+ local options: --baz
949
+ --bar
950
+ other options:
951
+ --egg
952
+ --spam
953
+ -not-an-option-
954
+
955
+ """
956
+ $ prog --baz --egg
957
+ {"--foo": false, "--baz": true, "--bar": false, "--egg": true, "--spam": false}