Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tj/commander.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.1.0
Choose a base ref
...
head repository: tj/commander.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.0.0
Choose a head ref

Commits on May 10, 2020

  1. Update dependencies and drop node 8 from testing (#1263)

    * Update depenencies
    
    * Drop node 8 from tests
    shadowspawn authored May 10, 2020
    Copy the full SHA
    790553d View commit details

Commits on May 14, 2020

  1. Replace indexOf with includes (#1264)

    * Replace indexOf with includes
    
    Changed the relevant if statement to an early return.
    
    * Modify to "StartsWith" to correspond to "indexOf === 0"
    abetomo authored May 14, 2020
    Copy the full SHA
    168ff5b View commit details

Commits on May 26, 2020

  1. Support options with only a short flag (#1256)

    * Support short flag alone
    
    * Weaken option parsing for backwards compatibility
    
    * Have .version allow short only flag
    
    * Add tests for lone short and long flags
    shadowspawn authored May 26, 2020
    Copy the full SHA
    a31bb3f View commit details

Commits on May 29, 2020

  1. Fix some typos

    Co-authored-by: Phillip Clark <phillip@flitbit.com>
    shadowspawn and Phillip Clark committed May 29, 2020
    Copy the full SHA
    24118fe View commit details

Commits on May 30, 2020

  1. Copy the full SHA
    4a7148a View commit details
  2. Copy the full SHA
    3798334 View commit details
  3. Copy the full SHA
    e9a6109 View commit details

Commits on Jun 1, 2020

  1. Add support for variadic options (#1250)

    * First cut at variadic option implementation
    
    * Rework variadic regexp
    - remove ellipsis for symmetry with .arguments
    - require word character before dots
    
    * Add tests for variadic options
    
    * Add test on non-variadic pattern
    
    * Rethink interation of variadic and coercion function
    
    * Fix typos
    
    * Raise ecmaVersion to eliminate some false positive errors in example files
    
    * Improve variadic option with optional value, zero or more values
    
    * Reorder comparison to match previous test
    
    * Use consistent test names
    
    * Add example and README for variadic option
    
    * Fix typo
    shadowspawn authored Jun 1, 2020
    Copy the full SHA
    913389f View commit details
  2. Feature/examples tidy (#1271)

    * Make all the examples executable
    
    * Add shebang to all examples
    
    * Remove use of global export as program in examples
    
    * Move .parse onto separate line in examples
    
    * Modify example to more closely match README
    
    * Reference example files where available (and remove require to keep length similar)
    
    * Remove example file which is not showing much, and covered in other files
    
    * Remove example file which is not showing much, and covered in other files
    
    * Add comment on point of file
    shadowspawn authored Jun 1, 2020
    Copy the full SHA
    6cad30a View commit details
  3. Copy the full SHA
    0576033 View commit details

Commits on Jun 15, 2020

  1. Throw for likely option name problems (#1275)

    * Make a start on warning for option name clashes with Command properties
    
    * Use correct property name for lookup
    
    * Shift clash detection into routine, still WIP
    
    * Prevent false positive clashes when negated option
    
    * Add tests for option name  clashes
    
    * Refine advice
    shadowspawn authored Jun 15, 2020
    Copy the full SHA
    42f61ca View commit details

Commits on Jun 18, 2020

  1. Copy the full SHA
    fc36472 View commit details

Commits on Jun 20, 2020

  1. Add link for 6.0.0-0

    shadowspawn committed Jun 20, 2020
    Copy the full SHA
    faac4d9 View commit details

Commits on Jun 22, 2020

  1. Feature/update dependencies (#1286)

    * Update dependencies
    
    * Refresh package-lock.json with clean install
    shadowspawn authored Jun 22, 2020
    Copy the full SHA
    ca2256e View commit details

Commits on Jul 4, 2020

  1. Optimize Chinese readme typesetting (#1289)

    * optimize Chinese typesetting
    
    add whitespace between Chinese and half-width characters (alphabetical letters, numerical digits and symbols) for good readability
    
    * Fix toc
    mastermay authored Jul 4, 2020
    Copy the full SHA
    09c103d View commit details

Commits on Jul 8, 2020

  1. Update supported versions (#1297)

    - update SECURITY
    - archive old CHANGELOG versions
    - update README
    shadowspawn authored Jul 8, 2020
    Copy the full SHA
    fdf6ee9 View commit details
  2. Add esm documentation (#1298)

    * Add esm documentation
    shadowspawn authored Jul 8, 2020
    Copy the full SHA
    3628571 View commit details

Commits on Jul 14, 2020

  1. update Chinese README (#1299)

    * doc: add Chinese translation for 6.x readme
    
    * doc: improve Chinese translation
    
    * doc: add esm document
    mastermay authored Jul 14, 2020
    Copy the full SHA
    601f2de View commit details

Commits on Jul 18, 2020

  1. Bump version for release

    shadowspawn committed Jul 18, 2020
    Copy the full SHA
    3c85087 View commit details

Commits on Jul 19, 2020

  1. Add regression test for #1301 (#1304)

    Co-author: snitin315@gmail.com
    shadowspawn authored Jul 19, 2020
    Copy the full SHA
    531a0fd View commit details
  2. Update dependencies except eslint (#1303)

    * Bump version for release
    
    * Update dependencies except eslint
    shadowspawn authored Jul 19, 2020
    Copy the full SHA
    394caef View commit details
  3. Copy the full SHA
    d7b179a View commit details
  4. Merge pull request #1305 from tj/release/6.x

    Release 6.0.0
    abetomo authored Jul 19, 2020
    Copy the full SHA
    c5a5e7b View commit details
Showing with 3,435 additions and 1,471 deletions.
  1. +6 −2 .eslintrc.js
  2. +1 −1 .github/workflows/tests.yml
  3. +2 −2 .travis.yml
  4. +24 −109 CHANGELOG.md
  5. +82 −36 Readme.md
  6. +196 −152 Readme_zh-CN.md
  7. +1 −2 SECURITY.md
  8. +12 −0 changelogs/CHANGELOG-2.md
  9. +103 −0 changelogs/CHANGELOG-3.md
  10. 0 examples/custom-command-class.js
  11. 0 examples/custom-command-function.js
  12. +5 −2 examples/custom-help
  13. +5 −2 examples/custom-help-description
  14. +8 −4 examples/custom-version
  15. +2 −0 examples/defaultCommand.js
  16. +8 −4 examples/defaults
  17. +3 −2 examples/deploy
  18. +8 −4 examples/description
  19. +5 −2 examples/env
  20. +0 −15 examples/express
  21. +0 −13 examples/help
  22. +2 −0 examples/nestedCommands.js
  23. 0 examples/options-custom-processing.js
  24. 0 examples/options-defaults.js
  25. 0 examples/options-flag-or-value.js
  26. +3 −2 examples/options-negatable.js
  27. 0 examples/options-required.js
  28. +21 −0 examples/options-variadic.js
  29. +6 −4 examples/pizza
  30. +9 −7 examples/pm
  31. +6 −4 examples/pm-install
  32. +3 −0 examples/pm-list.js
  33. +0 −1 examples/pm-publish.js
  34. 0 examples/storeOptionsAsProperties-action.js
  35. 0 examples/storeOptionsAsProperties-opts.js
  36. 0 examples/storeOptionsAsProperties-problem.js
  37. +138 −50 index.js
  38. +2,423 −1,000 package-lock.json
  39. +9 −9 package.json
  40. +1 −1 tests/command.addCommand.test.js
  41. +1 −1 tests/command.executableSubcommand.signals.test.js
  42. +1 −1 tests/command.exitOverride.test.js
  43. +1 −1 tests/command.help.test.js
  44. +62 −18 tests/command.helpOption.test.js
  45. +15 −15 tests/helpwrap.test.js
  46. +19 −0 tests/options.bool.test.js
  47. +52 −0 tests/options.detectClash.test.js
  48. +9 −2 tests/options.flags.test.js
  49. +1 −1 tests/options.mandatory.test.js
  50. +1 −1 tests/options.opts.test.js
  51. +156 −0 tests/options.variadic.test.js
  52. +24 −0 tests/options.version.test.js
  53. +1 −1 typings/index.d.ts
8 changes: 6 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ const javascriptSettings = {
'no-var': 'warn',
'one-var': 'off',
'space-before-function-paren': ['error', 'never'],
semi: ['error', 'always']
'semi': ['error', 'always']
},
}

@@ -24,7 +24,8 @@ const typescriptSettings = {
'no-var': 'warn',
'one-var': 'off',
'space-before-function-paren': ['error', 'never'],
semi: ['error', 'always'],
'semi': 'off',
'@typescript-eslint/semi': ['error', 'always'],
'@typescript-eslint/member-delimiter-style': [
'error',
{
@@ -43,6 +44,9 @@ const typescriptSettings = {

module.exports = {
plugins: ['jest'],
parserOptions: {
ecmaVersion: 8
},
overrides: [
javascriptSettings,
typescriptSettings
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [8.x, 10.x, 12.x, 14.x]
node-version: [10.x, 12.x, 14.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js:
- "8"
- "lts/*"
- "10"
- "lts/*"
- "node"
cache:
directories:
133 changes: 24 additions & 109 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,23 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). (Format adopted after v3.0.0.)

<!-- markdownlint-disable MD024 -->
<!-- markdownlint-disable MD004 -->

## [6.0.0] (2020-07-21)

### Added

- add support for variadic options ([#1250])
- allow options to be added with just a short flag ([#1256])
- throw an error if there might be a clash between option name and a Command property, with advice on how to resolve ([#1275])

### Fixed

- Options which contain -no- in the middle of the option flag should not be treated as negatable. ([#1301])

## [6.0.0-0] (2020-06-20)

(Released in 6.0.0)

## [5.1.0] (2020-04-25)

@@ -198,95 +215,9 @@ if (program.rawArgs.length < 3) ...

(Released in 4.0.0)

## [2.20.1] (2019-09-29)

### Fixed

* Improve tracking of executable subcommands.

### Changed

* update development dependencies

## [3.0.2] (2019-09-27)

### Fixed

* Improve tracking of executable subcommands.

### Changed

* update development dependencies

## [3.0.1] (2019-08-30)

### Added

* .name and .usage to README ([#1010])
* Table of Contents to README ([#1010])
* TypeScript definition for `executableFile` in CommandOptions ([#1028])

### Changed

* consistently use `const` rather than `var` in README ([#1026])

### Fixed

* help for sub commands with custom executableFile ([#1018])

## [3.0.0] / 2019-08-08

* Add option to specify executable file name ([#999])
* e.g. `.command('clone', 'clone description', { executableFile: 'myClone' })`
* Change docs for `.command` to contrast action handler vs git-style executable. ([#938] [#990])
* **Breaking** Change TypeScript to use overloaded function for `.command`. ([#938] [#990])
* Change to use straight quotes around strings in error messages (like 'this' instead of `this') ([#915])
* Add TypeScript "reference types" for node ([#974])
* Add support for hyphen as an option argument in subcommands ([#697])
* Add support for a short option flag and its value to be concatenated for action handler subcommands ([#599])
* e.g. `-p 80` can also be supplied as `-p80`
* Add executable arguments to spawn in win32, for git-style executables ([#611])
* e.g. `node --harmony myCommand.js clone`
* Add parent command as prefix of subcommand in help ([#980])
* Add optional custom description to `.version` ([#963])
* e.g. `program.version('0.0.1', '-v, --vers', 'output the current version')`
* Add `.helpOption(flags, description)` routine to customise help flags and description ([#963])
* e.g. `.helpOption('-e, --HELP', 'read more information')`
* Fix behavior of --no-* options ([#795])
* can now define both `--foo` and `--no-foo`
* **Breaking** custom event listeners: `--no-foo` on cli now emits `option:no-foo` (previously `option:foo`)
* **Breaking** default value: defining `--no-foo` after defining `--foo` leaves the default value unchanged (previously set it to false)
* allow boolean default value, such as from environment ([#987])
* Increment inspector port for spawned subcommands ([#991])
* e.g. `node --inspect myCommand.js clone`

### Migration Tips

The custom event for a negated option like `--no-foo` is `option:no-foo` (previously `option:foo`).

```js
program
.option('--no-foo')
.on('option:no-foo', () => {
console.log('removing foo');
});
```

When using TypeScript, adding a command does not allow an explicit `undefined` for an unwanted executable description (e.g
for a command with an action handler).

```js
program
.command('action1', undefined, { noHelp: true }) // No longer valid
.command('action2', { noHelp: true }) // Correct
```

## 3.0.0-0 Prerelease / 2019-07-28

(Released as 3.0.0)

## Older versions

* [3.x](./changelogs/CHANGELOG-3.md)
* [2.x](./changelogs/CHANGELOG-2.md)
* [1.x](./changelogs/CHANGELOG-1.md)
* [0.x](./changelogs/CHANGELOG-0.md)
@@ -296,34 +227,16 @@ program
[#508]: https://github.com/tj/commander.js/issues/508
[#512]: https://github.com/tj/commander.js/issues/512
[#531]: https://github.com/tj/commander.js/issues/531
[#599]: https://github.com/tj/commander.js/issues/599
[#611]: https://github.com/tj/commander.js/issues/611
[#645]: https://github.com/tj/commander.js/issues/645
[#697]: https://github.com/tj/commander.js/issues/697
[#742]: https://github.com/tj/commander.js/issues/742
[#764]: https://github.com/tj/commander.js/issues/764
[#795]: https://github.com/tj/commander.js/issues/795
[#802]: https://github.com/tj/commander.js/issues/802
[#806]: https://github.com/tj/commander.js/issues/806
[#809]: https://github.com/tj/commander.js/issues/809
[#915]: https://github.com/tj/commander.js/issues/915
[#938]: https://github.com/tj/commander.js/issues/938
[#948]: https://github.com/tj/commander.js/issues/948
[#962]: https://github.com/tj/commander.js/issues/962
[#963]: https://github.com/tj/commander.js/issues/963
[#974]: https://github.com/tj/commander.js/issues/974
[#980]: https://github.com/tj/commander.js/issues/980
[#987]: https://github.com/tj/commander.js/issues/987
[#990]: https://github.com/tj/commander.js/issues/990
[#991]: https://github.com/tj/commander.js/issues/991
[#993]: https://github.com/tj/commander.js/issues/993
[#995]: https://github.com/tj/commander.js/issues/995
[#999]: https://github.com/tj/commander.js/issues/999
[#1010]: https://github.com/tj/commander.js/pull/1010
[#1018]: https://github.com/tj/commander.js/pull/1018
[#1026]: https://github.com/tj/commander.js/pull/1026
[#1027]: https://github.com/tj/commander.js/pull/1027
[#1028]: https://github.com/tj/commander.js/pull/1028
[#1032]: https://github.com/tj/commander.js/issues/1032
[#1035]: https://github.com/tj/commander.js/pull/1035
[#1040]: https://github.com/tj/commander.js/pull/1040
@@ -364,8 +277,14 @@ program
[#1236]: https://github.com/tj/commander.js/pull/1236
[#1247]: https://github.com/tj/commander.js/pull/1247
[#1248]: https://github.com/tj/commander.js/pull/1248
[#1250]: https://github.com/tj/commander.js/pull/1250
[#1256]: https://github.com/tj/commander.js/pull/1256
[#1275]: https://github.com/tj/commander.js/pull/1275
[#1301]: https://github.com/tj/commander.js/issues/1301

[Unreleased]: https://github.com/tj/commander.js/compare/master...develop
[6.0.0]: https://github.com/tj/commander.js/compare/v5.1.0..v6.0.0
[6.0.0-0]: https://github.com/tj/commander.js/compare/v5.1.0..v6.0.0-0
[5.1.0]: https://github.com/tj/commander.js/compare/v5.0.0..v5.1.0
[5.0.0]: https://github.com/tj/commander.js/compare/v4.1.1..v5.0.0
[5.0.0-4]: https://github.com/tj/commander.js/compare/v5.0.0-3..v5.0.0-4
@@ -379,7 +298,3 @@ program
[4.0.0]: https://github.com/tj/commander.js/compare/v3.0.2..v4.0.0
[4.0.0-1]: https://github.com/tj/commander.js/compare/v4.0.0-0..v4.0.0-1
[4.0.0-0]: https://github.com/tj/commander.js/compare/v3.0.2...v4.0.0-0
[3.0.2]: https://github.com/tj/commander.js/compare/v3.0.1...v3.0.2
[3.0.1]: https://github.com/tj/commander.js/compare/v3.0.0...v3.0.1
[3.0.0]: https://github.com/tj/commander.js/compare/v2.20.1...v3.0.0
[2.20.1]: https://github.com/tj/commander.js/compare/v2.20.0...v2.20.1
Loading