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: v2.20.3
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: v3.0.0
Choose a head ref
Loading
Showing with 2,146 additions and 1,275 deletions.
  1. +12 −0 .editorconfig
  2. +40 −0 .github/CONTRIBUTING.md
  3. +1 −2 .travis.yml
  4. +67 −0 CHANGELOG.md
  5. +282 −140 Readme.md
  6. +237 −55 Readme_zh-CN.md
  7. +15 −0 SECURITY.md
  8. +0 −46 examples/coercion
  9. +21 −0 examples/custom-help-description
  10. +13 −0 examples/custom-version
  11. +36 −0 examples/options-common.js
  12. +53 −0 examples/options-custom-processing.js
  13. +22 −0 examples/options-defaults.js
  14. +26 −0 examples/options-flag-or-value.js
  15. +29 −0 examples/options-negatable.js
  16. +2 −4 examples/pizza
  17. +0 −17 examples/regex
  18. +221 −113 index.js
  19. +595 −772 package-lock.json
  20. +7 −7 package.json
  21. +1 −0 test/fixtures/inspect-sub.js
  22. +7 −0 test/fixtures/inspect.js
  23. +3 −1 test/fixtures/pm
  24. +50 −0 test/test.command.executableSubcommand.inspect.js
  25. +44 −0 test/test.command.executableSubcommandSpecifySubcommand.js
  26. +46 −0 test/test.command.helpInformation.custom.js
  27. +65 −0 test/test.command.helpSubCommand.customFlags.js
  28. +8 −0 test/test.command.usage.js
  29. +1 −1 test/test.options.args.required.js
  30. +19 −12 test/test.options.bool.js
  31. +60 −12 test/test.options.bool.no.js
  32. +2 −6 test/test.options.bool.small.js
  33. +8 −9 test/test.options.defaults.given.js
  34. +8 −11 test/test.options.defaults.js
  35. +23 −0 test/test.options.defaults.no.js
  36. +18 −0 test/test.options.short.adjacent-value.js
  37. +21 −0 test/test.options.subcommand-hyphen.js
  38. +22 −0 test/test.options.version.customHelpDescription.js
  39. +1 −1 test/test.variadic.args.js
  40. +6 −1 typings/commander-tests.ts
  41. +54 −65 typings/index.d.ts
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
tab_width = 2
# trim_trailing_whitespace = true
40 changes: 40 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing

## Issues

New issues are welcome, whether questions or suggestions or reporting bugs.
You are also welcome to contribute by adding helpful comments on an existing issue.

We love reproducible code examples in questions and answers.

If you get a satisfactory reply to a question then please close your issue, but it is ok to leave an issue open for more replies or interest. Inactive issues may get closed after one month if they have an answer,
or after six months otherwise.

## Pull Requests

Pull Requests will be considered. Please submit pull requests against the develop branch.

Follow the existing code style. Check the tests succeed, including lint.

Don't update the CHANGELOG or command version number. That gets done by maintainers when preparing the release.

Useful things to include in your request description are:

- what problem are you solving?
- what Issues does this relate to?
- suggested summary for CHANGELOG

There are a lot of forms of documentation which could need updating for a change in functionality. It
is ok if you want to show us the code to discuss before doing the extra work, and
you should say so in your comments so we focus on the concept first before talking about all the other pieces:

- TypeScript typings
- JSDoc documentation in code
- tests
- README
- examples/

Commander currently has zero production dependencies. That isn't a hard requirement, but is a simple story. Requests which add a dependency are much less likely to be accepted, and we are likely to ask if there alternative approaches to avoid the dependency.

- <https://devrant.com/rants/1854993/package-tsunami>
- <https://dev.to/leoat12/the-nodemodules-problem-29dc>
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: node_js
sudo: false
node_js:
- "6"
- "8"
- "10"
- "12"
cache:
directories:
- "node_modules"
67 changes: 67 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
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`

Example Breaking Changes
------------------------

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
```

[#599]: https://github.com/tj/commander.js/issues/599
[#611]: https://github.com/tj/commander.js/issues/611
[#697]: https://github.com/tj/commander.js/issues/697
[#795]: https://github.com/tj/commander.js/issues/795
[#915]: https://github.com/tj/commander.js/issues/915
[#938]: https://github.com/tj/commander.js/issues/938
[#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
[#999]: https://github.com/tj/commander.js/issues/999

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

(Released as 3.0.0)

2.20.0 / 2019-04-02
==================
Loading