commander 7.0.0-1 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,49 +8,170 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
8
8
  <!-- markdownlint-disable MD024 -->
9
9
  <!-- markdownlint-disable MD004 -->
10
10
 
11
- ## [7.0.0-1] (2020-11-21)
11
+ ## [7.2.0] (2021-03-26)
12
12
 
13
13
  ### Added
14
14
 
15
- - `.createOption()` to support subclassing of automatically created options (like `.createCommand()`) ([#1380])
16
- - `.configureOutput()` to modify use of stdout and stderr or customise display of errors ([#1387])
15
+ - TypeScript typing for `parent` property on `Command` ([#1475])
16
+ - TypeScript typing for `.attributeName()` on `Option` ([#1483])
17
+ - support information in package ([#1477])
17
18
 
18
- ### Breaking changes relative to 7.0.0-0
19
+ ### Changed
19
20
 
20
- - rework new `Help.wrap()` for simpler usage pattern (#1395)
21
- - rename new "columns" properties (#1396)
22
- - `Help.columns` -> `helpWidth`
23
- - `getOutColumns()` -> `getOutHelpWidth()`
24
- - `getErrColumns()` -> `getErrHelpWidth()`
21
+ - improvements to error messages, README, and tests
22
+ - update dependencies
25
23
 
26
- ## [7.0.0-0] (2020-10-25)
24
+ ## [7.1.0] (2021-02-15)
25
+
26
+ ### Added
27
+
28
+ - support for named imports from ECMAScript modules ([#1440])
29
+ - add `.cjs` to list of expected script file extensions ([#1449])
30
+ - allow using option choices and variadic together ([#1454])
31
+
32
+ ### Fixed
33
+
34
+ - replace use of deprecated `process.mainModule` ([#1448])
35
+ - regression for legacy `command('*')` and call when command line includes options ([#1464])
36
+ - regression for `on('command:*', ...)` and call when command line includes unknown options ([#1464])
37
+ - display best error for combination of unknown command and unknown option (i.e. unknown command) ([#1464])
38
+
39
+ ### Changed
40
+
41
+ - make TypeScript typings tests stricter ([#1453])
42
+ - improvements to README and tests
43
+
44
+ ## [7.0.0] (2021-01-15)
27
45
 
28
46
  ### Added
29
47
 
48
+ - `.enablePositionalOptions()` to let program and subcommand reuse same option ([#1427])
49
+ - `.passThroughOptions()` to pass options through to other programs without needing `--` ([#1427])
50
+ - `.allowExcessArguments(false)` to show an error message if there are too many command-arguments on command line for the action handler ([#1409])
51
+ - `.configureOutput()` to modify use of stdout and stderr or customise display of errors ([#1387])
30
52
  - use `.addHelpText()` to add text before or after the built-in help, for just current command or also for all subcommands ([#1296])
31
53
  - enhance Option class ([#1331])
32
54
  - allow hiding options from help
33
55
  - allow restricting option arguments to a list of choices
34
56
  - allow setting how default value is shown in help
57
+ - `.createOption()` to support subclassing of automatically created options (like `.createCommand()`) ([#1380])
35
58
  - refactor the code generating the help into a separate public Help class ([#1365])
36
59
  - support sorting subcommands and options in help
37
60
  - support specifying wrap width (columns)
38
61
  - allow subclassing Help class
39
62
  - allow configuring Help class without subclassing
40
-
63
+
64
+ ### Changed
65
+
66
+ - *Breaking:* options are stored safely by default, not as properties on the command ([#1409])
67
+ - this especially affects accessing options on program, use `program.opts()`
68
+ - revert behaviour with `.storeOptionsAsProperties()`
69
+ - *Breaking:* action handlers are passed options and command separately ([#1409])
70
+ - deprecated callback parameter to `.help()` and `.outputHelp()` (removed from README) ([#1296])
71
+ - *Breaking:* errors now displayed using `process.stderr.write()` instead of `console.error()`
72
+ - deprecate `.on('--help')` (removed from README) ([#1296])
73
+ - initialise the command description to empty string (previously undefined) ([#1365])
74
+ - document and annotate deprecated routines ([#1349])
75
+
41
76
  ### Fixed
42
77
 
43
78
  - wrapping bugs in help ([#1365])
44
79
  - first line of command description was wrapping two characters early
45
80
  - pad width calculation was not including help option and help command
46
81
  - pad width calculation was including hidden options and commands
82
+ - improve backwards compatibility for custom command event listeners ([#1403])
47
83
 
48
- ### Changed
84
+ ### Deleted
49
85
 
50
- - document and annotate deprecated routines ([#1349])
51
- - deprecated callback parameter to `.help()` and `.outputHelp()` (removed from README) ([#1296])
52
- - deprecate `.on('--help')` (removed from README) ([#1296])
53
- - initialise the command description to empty string (previously undefined) ([#1365])
86
+ - *Breaking:* `.passCommandToAction()` ([#1409])
87
+ - no longer needed as action handler is passed options and command
88
+ - *Breaking:* "extra arguments" parameter to action handler ([#1409])
89
+ - if being used to detect excess arguments, there is now an error available by setting `.allowExcessArguments(false)`
90
+
91
+ ### Migration Tips
92
+
93
+ The biggest change is the parsed option values. Previously the options were stored by default as properties on the command object, and now the options are stored separately.
94
+
95
+ If you wish to restore the old behaviour and get running quickly you can call `.storeOptionsAsProperties()`.
96
+ To allow you to move to the new code patterns incrementally, the action handler will be passed the command _twice_,
97
+ to match the new "options" and "command" parameters (see below).
98
+
99
+ **program options**
100
+
101
+ Use the `.opts()` method to access the options. This is available on any command but is used most with the program.
102
+
103
+ ```js
104
+ program.option('-d, --debug');
105
+ program.parse();
106
+ // Old code before Commander 7
107
+ if (program.debug) console.log(`Program name is ${program.name()}`);
108
+ ```
109
+
110
+ ```js
111
+ // New code
112
+ const options = program.opts();
113
+ if (options.debug) console.log(`Program name is ${program.name()}`);
114
+ ```
115
+
116
+ **action handler**
117
+
118
+ The action handler gets passed a parameter for each command-argument you declared. Previously by default the next parameter was the command object with the options as properties. Now the next two parameters are instead the options and the command. If you
119
+ only accessed the options there may be no code changes required.
120
+
121
+ ```js
122
+ program
123
+ .command('compress <filename>')
124
+ .option('-t, --trace')
125
+ // Old code before Commander 7
126
+ .action((filename, cmd)) => {
127
+ if (cmd.trace) console.log(`Command name is ${cmd.name()}`);
128
+ });
129
+ ```
130
+
131
+ ```js
132
+ // New code
133
+ .action((filename, options, command)) => {
134
+ if (options.trace) console.log(`Command name is ${command.name()}`);
135
+ });
136
+ ```
137
+
138
+ If you already set `.storeOptionsAsProperties(false)` you may still need to adjust your code.
139
+
140
+ ```js
141
+ program
142
+ .command('compress <filename>')
143
+ .storeOptionsAsProperties(false)
144
+ .option('-t, --trace')
145
+ // Old code before Commander 7
146
+ .action((filename, command)) => {
147
+ if (command.opts().trace) console.log(`Command name is ${command.name()}`);
148
+ });
149
+ ```
150
+
151
+ ```js
152
+ // New code
153
+ .action((filename, options, command)) => {
154
+ if (command.opts().trace) console.log(`Command name is ${command.name()}`);
155
+ });
156
+ ```
157
+
158
+ ## [7.0.0-2] (2020-12-14)
159
+
160
+ (Released in 7.0.0)
161
+
162
+ ## [7.0.0-1] (2020-11-21)
163
+
164
+ (Released in 7.0.0)
165
+
166
+ ## [7.0.0-0] (2020-10-25)
167
+
168
+ (Released in 7.0.0)
169
+
170
+ ## [6.2.1] (2020-12-13)
171
+
172
+ ### Fixed
173
+
174
+ - some tests failed if directory path included a space ([1390])
54
175
 
55
176
  ## [6.2.0] (2020-10-25)
56
177
 
@@ -284,10 +405,28 @@ to expand `-fb` to `-f -b` rather than `-f b`.
284
405
  [#1375]: https://github.com/tj/commander.js/pull/1375
285
406
  [#1380]: https://github.com/tj/commander.js/pull/1380
286
407
  [#1387]: https://github.com/tj/commander.js/pull/1387
408
+ [#1390]: https://github.com/tj/commander.js/pull/1390
409
+ [#1403]: https://github.com/tj/commander.js/pull/1403
410
+ [#1409]: https://github.com/tj/commander.js/pull/1409
411
+ [#1427]: https://github.com/tj/commander.js/pull/1427
412
+ [#1440]: https://github.com/tj/commander.js/pull/1440
413
+ [#1448]: https://github.com/tj/commander.js/pull/1448
414
+ [#1449]: https://github.com/tj/commander.js/pull/1449
415
+ [#1453]: https://github.com/tj/commander.js/pull/1453
416
+ [#1454]: https://github.com/tj/commander.js/pull/1454
417
+ [#1464]: https://github.com/tj/commander.js/pull/1464
418
+ [#1475]: https://github.com/tj/commander.js/pull/1475
419
+ [#1477]: https://github.com/tj/commander.js/pull/1477
420
+ [#1483]: https://github.com/tj/commander.js/pull/1483
287
421
 
288
422
  [Unreleased]: https://github.com/tj/commander.js/compare/master...develop
423
+ [7.2.0]: https://github.com/tj/commander.js/compare/v7.1.0...v7.2.0
424
+ [7.1.0]: https://github.com/tj/commander.js/compare/v7.0.0...v7.1.0
425
+ [7.0.0]: https://github.com/tj/commander.js/compare/v6.2.1...v7.0.0
426
+ [7.0.0-2]: https://github.com/tj/commander.js/compare/v7.0.0-1...v7.0.0-2
289
427
  [7.0.0-1]: https://github.com/tj/commander.js/compare/v7.0.0-0...v7.0.0-1
290
428
  [7.0.0-0]: https://github.com/tj/commander.js/compare/v6.2.0...v7.0.0-0
429
+ [6.2.1]: https://github.com/tj/commander.js/compare/v6.2.0..v6.2.1
291
430
  [6.2.0]: https://github.com/tj/commander.js/compare/v6.1.0..v6.2.0
292
431
  [6.1.0]: https://github.com/tj/commander.js/compare/v6.0.0..v6.1.0
293
432
  [6.0.0]: https://github.com/tj/commander.js/compare/v5.1.0..v6.0.0