Debian Codegraph @

Changelog.markdown

raw symbols SCIP
1 # Changelog file for CLAP
2
3 This file describes changes in CLAP codebase, usage, public and private API and documentation.
4 It's mostly useful for developers who use the CLAP library.
5
6 #### Rules
7
8 * __fix__: bug fixes,
9 * __upd__: updated feature,
10 * __new__: new features,
11 * __dep__: deprecated features (scheduled for removal in next *n* versions),
12 * __rem__: removed features,
13
14
15 ----
16
17 ## Version 0.11.0 (2016-09-02)
18
19 This long awaited release improves both documentation and code.
20 Documentation was expanded with updated examples and README-style articles explaining how to use CLAP.
21
22 On the code front, there are several imporvements.
23
24 ### Shortened command names
25
26 From day-one CLAP supported short and long option names.
27 People who use a piece of software frequently usually memorise short versions of commonly used options, but
28 for a very long time CLAP did not provide a way to shorten the *command* names.
29 This mean that even long command names must have been written in full:
30
31 ```
32 ~]$ program some-nested command-name that-is-too --verbose --and long-to-type --foo --with spam
33 ```
34
35 Now, the above invocation can be shortened to just:
36
37 ```
38 ~]$ program s c t --verbose --and l --foo --with spam
39 ```
40
41 CLAP detects that a mode has nested modes, and automatically expands the shortened command name.
42 Expansion fails if the command name is ambiguous, i.e. when more two or more subcommands exist (e.g. `foo` and `far`) and
43 both share a common prefix that, and only this prefix was given to CLAP.
44
45
46 ### Fixed rendering detailed option help
47
48 Detailed option help (`program help command subcommand --option`) now renders all help available for requested option.
49
50
51 ### Better automatically generated help for option arguments
52
53 CLAP provides a way to describe individual option arguments, and provide more detailed help messages.
54 Use `argument-name:argument-type` syntax when definition option arguments:
55
56 ```
57 {
58 "short": "p",
59 "long": "phone-no",
60 "arguments": ["use +NN.AAABBBCCC format:str"]
61 }
62 ```
63
64
65
66 ----
67
68
69 ## Version 0.10.0-rc.3 (2014-07-)
70
71 This release candidate adds two more parameters to the already available palette of
72 customization options for CLAP options.
73
74 Note that however promising the `defaults` option may sound it can currently be only used to provide values
75 for options added by CLAP (when running through `implies` hooks).
76 Support for omitting arguments was not coded to keep the complexity of the parser on an acceptable level.
77 Said complexity has to be decreased nevertheless, because the `implies` hook that became available to developers caused
78 the complexity level of parser to raise considerably.
79
80 Even though, optional arguments should be requested as operands - it is safer and easier to manage them this way.
81
82 This release candidate is not big in terms of List of Changes, but is *huge* in terms of functionality added.
83
84 - **new**: `implies` parameter in `clap.option.Option`,
85 - **new**: `defaults` parameter in `clap.option.Option`,
86 - **new**: `conflicts()` method in `clap.option.Option`,
87
88 - **fix**: checker can now correctly detect more cases when not enough arguments are provided to an option (i.e. instead of rising
89 the invalid-type exception it will raise the missing-argument exception when the item that caused it in the first place is
90 an option accepted by parser),
91
92
93 ----
94
95 ## Version 0.10.0-rc.2 (2014-07-09)
96
97 - **fix**: fixed bug introduced in 0.9.6 which cause help runner to crash if help was requested by option,
98
99 - **upd**: examples are no longer included in the full rendering of help screen, they need to be separately viewed,
100
101
102 ----
103
104 ## Version 0.10.0-rc.1 (2014-07-08)
105
106 All deprecated features were removed from code.
107
108 - **upd**: `addMode()` method of `RedMode` renamed to `addCommand()`,
109 - **upd**: `hasmode()` method of `RedMode` renamed to `hasCommand()`,
110 - **upd**: `getmode()` method of `RedMode` renamed to `getCommand()`,
111 - **upd**: `modes()` method of `RedMode` renamed to `commands()`,
112 - **upd**: `mode` parameter in `clap.builder.export()` function renamed to `command`,
113 - **upd**: `RedMode` class renamed to `RedCommand`,
114 - **upd**: `UnrecognizedModeError` renamed to `UnrecognizedCommandError`,
115
116 - **rem**: removed support for features deprecated in 0.9.x line,
117 - **rem**: `readfile()` and `readjson()` functions were removed from `clap.builder` module,
118
119 ----
120
121 ## Version 0.9.6 (2014-07-04)
122
123 It seems like the 0.9.x line is about to stay for a bit longer than I expected.
124 However, it does not mean there are no improvements in the code.
125
126 One new feature is the `"examples"` key in `"doc"` field of the top-level command.
127 Apart from usage, which describes more abstract syntax, the examples are used to
128 provide real-life invocations of the program.
129 This field may change in future (currently it is built the same way as usage) to incorporate
130 brief explanation what does the line do:
131
132 ```
133 "examples": [
134 {
135 "line": "foo --bar baz -xy",
136 "desc": "this line does something"
137 }
138 ]
139 ```
140
141 Would yield something akin to:
142
143 ```
144 Examples:
145
146 program foo --bar baz -xy
147 this line does something
148 ```
149
150 This release brings another new feature: Help Runner.
151 It is an object which takes parsed UI and analyses it to tell whether user wanted to see help
152 screen or not; in either case it will act accordingly, and report the outcome to the program
153 developer (in code).
154 As such, it shifts the burden of managing help screens yet further away from the developers so
155 that the library can do even more of the heavy lifting.
156
157 Currently, the help runner does not offer many customization hooks (only option-triggers can be adjusted), yet it comes with sane defaults:
158
159 - `-h` and `--help` options trigger help screen display,
160 - `help` as first (second, technically) command triggers help display.
161
162 The help runner can be more easily integrated into programs using `Builder` object using its `insertHelpCommand()` method which,
163 as the name says, inserts a model of `help` command into model of UI as a child of main command.
164 The call looks this way: `mode = clap.builder.Builder(model).insertHelpCommand().build().get()`
165
166 Apart from these new features, there is a deprecation also: *verb commands* (akin to Git's `commit`, `pull` or `stash`) are no longer `modes` in JSON
167 representations of UIs, but are `commands`.
168 There is a warning about this in code so CLAP will yell about UIs that are not upgraded.
169
170
171 - **new**: `examples` key in `doc` field of JSON UI representations, **examples should only be set in doc for the TOP LEVEL command **,
172 - **new**: `HelpRunner` object in `clap.helper` module,
173 - **new**: `top()` method in `ParsedUI`,
174 - **new**: `usage()` and `examples()` methods in `Helper`,
175 - **new**: `insertHelpCommand()` method added to `Builder`, which makes integration with Help Runner easier and
176 provides unified help interface for users of CLAP library,
177
178 - **upd**: `Helper` was refactored a little bit,
179 - **upd**: parser undergone major refactoring, actual parsing logic has been broken down into several smaller, easier to understand methods;
180 maybe a separate class should be created as `Parser` seems to have too much responsibility,
181
182 - **dep**: `modes` field in JSON UI representations, changed to `commands`,
183 - **dep**: `gen` method in `Helper`, use `full` instead,
184
185 - **rem**: `get()` method from `Parser`,
186 - **rem**: `getoperands()` method from `Parser`,
187 - **rem**: `clap_typehandler.py` method of setting typehandlers for CLAP,
188
189
190 ----
191
192 ## Version 0.9.5 (2014-06-21)
193
194 CLAP is now building better help screens, greatest improvement can be seen in how descriptions of commands (sub modes) are rendered, i.e.
195 the name of the submode is followed by a two-space break and a description of it so users can quickly check what command they want to use.
196
197 This release also fixes a bug which caused an error about unrecognized option to be incorrectly raised.
198
199 - **new**: command descriptions in abbreviated help screens,
200 - **new**: slightly refactored help screen generator and help screens' look is slightly different,
201 - **new**: new way of building doc in JSON, added `"doc"` field (with `"help"` and `"usage"` keys),
202
203 - **dep**: `"help": ` key of mode is moved to `"doc"` field,
204
205 - **fix**: unrecognized option error incorrectly raised when aliases are passed,
206
207
208 ----
209
210 ## Version 0.9.4 (2014-06-16)
211
212 CLAP is able to build full or abbreviated help screens.
213 Abbreviated help screens show help only for top-level mode, i.e. its
214 options - local and global - and commands.
215 Full help screen displays help for all sub-commands.
216
217 Also, in this release CLAP code was moved back from `redclap/` to `clap/`.
218
219 Finally, 0.9.4 is most probably last release from 0.9.x line and
220 the next version of CLAP will mark the beginning of the 0.10.x line.
221
222
223 - **new**: full help screens,
224 - **new**: abbreviated help screens,
225
226 - **fix**: checker now correctly handles one more case of unrecognized option,
227
228
229 ----
230
231 ## Version 0.9.3 (2014-06-10)
232
233 CLAP can build UIs from JSON descriptions and
234 export UIs built directly in Python to JSON (exporting is work-in-progress and needs more testing, though).
235
236 Another feature implemented in this release is help screen generation, but currently to only one level of depth.
237 This will be fixed in later releases.
238
239
240 - **new**: building interfaces from JSON,
241 - **new**: exporting interfaces written in Python to JSON,
242 - **new**: generating help screens,
243 - **new**: more fluent interface for formatter,
244
245 - **fix**: bug in parser, which returned items for nested mode even if mode accepted no child modes,
246
247 - **rem**: old CLAP code,
248 - **rem**: old CLAP tests,
249 - **rem**: old checker code from RedCLAP module,
250
251
252 ----
253
254 ## Version 0.9.2 (2014-06-07)
255
256 This is the first version of RedCLAP, i.e. *Redesigned CLAP* and is not backwards compatible with previous release.
257 However, it brings major improvements to the code.
258
259 Notable new features are *operand ranges*, a method for designer to set a range of operands accepted by CLAP and
260 let CLAP validate them, and *plural options* - which tell CLAP to not overwrite the previously found value of an options but
261 rather build a list of all values passed (in case of options that take no arguments - to count how many times they occurred).
262 This provides for greater control over user input.
263
264 Another feature is just a huge bugfix. Nested modes are finally working properly.
265 The can be nested *ad infinitum*, all can have operands with set ranges, all can have global and local options.
266
267 Successful improvement was done on the front of UI building.
268 Global options can now be added freely - after or before modes are added and are *propagated* to nested modes after the
269 (who would have guessed) `.propagate()` method is called on the top level mode.
270
271
272 - **new**: [`DESIGN.markdown`](./DESIGN.markdown) file has been added,
273 - **new**: development moved to `redclap/` directory while `clap/` contains old, untouched code from 0.9.1 release,
274 - **new**: operand ranges,
275 - **new**: new behavior of `.get()` method of parsed UI,
276 - **new**: plural options,
277
278 - **fix**: nested modes,
279 - **fix**: global options propagation,
280
281 - **rem**: old JSON UIs must be ported to new JSON spec,
282 - **rem**: CLAP v0.9.2 changed Python APIs for building UIs,
283
284
285 ----
286
287 #### Version 0.9.1 (2013-11-09):
288
289 Deprecated module `clap.modes` was removed.
290 If you haven't changed your code when update 0.9.0 arrived you must do it now.
291 Now, `clap.parser.Parser` supports both single and
292 nested parsers.
293
294 * __rem__: `clap.modes` module was removed,
295
296
297 ----
298
299 #### Version 0.9.0 (2013-11-):
300
301 From this version `clap.modes.Parser` is deprecated - single and nested parsers were unified and
302 now you can use `clap.parser.Parser` with modes (the API was copied from `clap.modes.Parser`).
303
304
305 * __new__: `clap.parser.Parser().finalize()` method which will define the parser and parse it via a single call,
306 * __new__: `clap.shared` module containing functions and variables shared between various CLAP modules,
307 * __new__: `clap.base.Base`, `clap.parser.Parser` and `clap.modes.Parser` got new `getoperands()` method,
308 * __new__: `clap.base.Base` and `clap.parser.Parser` have `__eq__()` method overloaded (comparing with `==` will be now possible),
309
310 * __upd__: better help message generation,
311 * __upd__: moved option regular expression patterns from `clap.base` to `clap.shared`,
312 * __upd__: moved `lookslikeopt()` function from `clap.base` to `clap.shared`,
313 * __upd__: information about default parser is now private,
314
315 * __rem__: `lines` parameter from `Helper().help()` method - now it returns only list of strings,
316
317
318 ----
319
320 #### Version 0.8.4 (2013-09-02):
321
322 * __fix__: type handlers are applied also to nested parsers,
323
324
325 ----
326
327 #### Version 0.8.3 (2013-08-31):
328
329 * __fix__: fixed bug which prevented building JSON interfaces with local mode-options,
330
331
332 ----
333
334 #### Version 0.8.2 (2013-08-31):
335
336 * __new__: support for non-global options given to modes (helps writing modes which act more like parsers),
337
338
339 ----
340
341 #### Version 0.8.1 (2013-08-31):
342
343 This version **is not backwards compatible**! You'll need to fix your JSON and/or Python built interfaces
344 for the new stuff - `needs` was renamed to `wants`, `NeededOptionNotFoundError` was renamed to `WantedOption...`.
345
346 * __upd__: order in which validating methods are called (conflicts are checked just after
347 unrecognized options to prevent typing a lot and getting an error about conflicting
348 options),
349 * __upd__: `needs` arguments renamed to `wants` in all places,
350 * __upd__: `clap.checker.Checker._checkneeds` renamed to `clap.checker.Checker._checkwants`,
351 * __upd__: `clap.errors.NeededOptionNotFoundError` renamed to `clap.errors.WantedOptionNotFoundError`,
352
353 * __new__: `BuilderError` in `clap.errors`, raised when builder loads invalid JSON
354 * __new__: `UIDesignError` in `clap.errors`, raised when one option requires another option
355 which is undefined,
356 * __new__: `parser` and `modes` arguments in `Builder.build()` for forcing build of given type,
357 keep in mind that they are provided as a debug feature for JSON interfaces (type-detection
358 should work without them),
359 * __new__: `clap.helper.Helper` which can build help information from parsers,
360 * __new__: `help` argument for options,
361
362
363 ----
364
365 #### Version 0.7.5 (2013-08-14):
366
367 This version fixes type-detection issues with JSON-based interfaces (well, they are still alpha/beta).
368 Pure Python API is free from these bugs.
369
370
371 ----
372
373 #### Version 0.7.4 (2013-08-07):
374
375 This version brings support for creating nested modes in JSON interfaces.
376 Apart from this, some refactoring had been done in `clap/builder.py`.
377 `clap.builder.ModesParser()` is no longer there - only object that is needed
378 to build an interface is `clap.builder.Builder()`.
379 Builder functions, and element-type recognition functions, are exposed so you can
380 use them directly with no need to initialize builder object.
381 However, I don't see a need for this - if you would want to translate dicts and
382 lists to interfaces and bother with all the stuff around them it's easier to just
383 code the whole interface by hand. This functionality will never be removed.
384
385 * __new__: `isparser()`, `isoption()` and `ismodesparser()` functions in `clap.builder`,
386 * __new__: `buildparser()` and `buildmodesparser()` functions in `clap.builder`,
387
388 * __upd__: `clap.builder.Builder()` is no longer limited to simple parsers - it can
389 now build also single- and nested-modes parsers.
390
391 * __rem__: `clap.builder.ModesParser()` is removed and it's functionality is now in
392 `clap.builder.Builder()`
393
394 ----
395
396 #### Version 0.7.3 (2013-08-06):
397
398 This version debugs stuff (I hope) and let's you create simple-parser interfaces using
399 `clap.builder.Builder()` object (without need for `clap.builder.Parser()`.
400
401 * __new__: `clap.builder.Builder().build()` let's you build simple-parser interfaces,
402 * __new__: `clap.builder.Builder()._applyhandlersto()` method returns parser with applied
403 type handlers,
404
405 * __rem__: `clap.builder.Parser()` object is removed,
406
407
408 ----
409
410 #### Version 0.7.2 (2013-08-05):
411
412 This version brings support for creating interfaces using JSON.
413
414 * __new__: `clap.builder` module containing `Parser()` and `ModesParser()` objects used for building interfaces,
415
416
417 ----
418
419 #### Version 0.7.1 (2013-08-04):
420
421 This version is capable of having *nested modes*, e.g. syntax like `foo bar baz --some --fancy options --after --this`.
422 Such behavior needed some changes in code to be done and this resulted in `check()` method of `modes.Parser()`
423 automatically calling define before any actual checking is done.
424
425 **Notice**: it's possible that in version 0.7.2 `modes.Parser()` will be renamed to prevent it being mistaken for `parser.Parser()` and
426 to improve accuracy of error messages.
427
428
429 * __fix__: fixed bug in `clap.modes.Parser().addOption()` (I forgot to port it to the new version of options)
430
431 * __new__: `_append()` method on `clap.modes.Parser()`
432 * __new__: you can now nest modes,
433 * __new__: `_getarguments()` method in `clap.base.Base()`
434
435 * __upd__: there is no need to call `define()` before `check()` on `modes.Parser()` - the latter automatically calls the former,
436 * __upd__: `type()` now returns empty list if option takes no arguments,
437
438
439 ----
440
441 #### Version 0.7.0 (2013-08-03):
442
443 **Warning**: this release is not backwards compatible, you'll need to port your software to it.
444 However, only small adjustments will be needed and only the *in* part of the API changes and *out*
445 remains the same (not quite, it is more powerful now).
446
447
448 * __fix__: fixed bug in `base.Base._getinput()` which caused it to return whole argv when it should return empty list
449
450 * __new__: it is possible to specify multiple arguments for an option (defined as a list, returned as a tuple of arguments),
451
452 * __upd__: `argument` parameter renamed to `arguments` in all methods and functions,
453
454
455 ----
456
457 #### Version 0.6.3 (2013-08-02):
458
459 * __fix__: fixed bug in `Parser._checkneeds()` which caused `needs` param to behave like `requires`
460 * __fix__: fixed bug in `Parser._checkneeds()` which caused it to raise an exception if parameter `needs` was empty list,
461
462 * __upd__: updated regular expressions used for option string recognition,
463
464 * __new__: `clap/base.py` module,
465 * __new__: `clap/checker.py` module,
466 * __new__: first test suite added,
467
468 * __rem__: `hint` parameter is removed from all CLAP components,
469
470
471 ----
472
473 #### Version 0.6.2 (2013-07-12):
474
475 * __upd__: `modes.Modes()` renamed to `modes.Parser()`
476 * __new__: `_getinput()` method in `parser.Parser()` added another security layer to checks
477
478
479 ----
480
481 #### Version 0.2.3 (2013-06-29):
482
483 * __new__: `required` optional argument in `clap.Parser.add()`, if passed and option is not found in input when `check()`ing error is raised,
484 * __new__: `gethint()` method in `clap.Parser`,
485
486
487 ----
488
489 #### Version 0.2.2 (2013-06-29):
490
491 * __upd__: if option requires no argument `None` is returned instead of raising `TypeError`
492
493
494 * __fix__:
495
496
497 * __new__: