diff --git a/CHANGELOG.md b/CHANGELOG.md index 01d9bc224..73b9886e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,47 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. -## [5.0.0-4] (2020-03-03) - -### Added - -* `createCommand` factory method to simplify subclassing ([#1191]) - -## [5.0.0-3] (2020-02-20) - -### Added - -* TypeScript definition for `commands` property of `Command` ([#1184]) -* export `program` property ([#1195]) - -## [5.0.0-2] (2020-02-10) - -### Added - -* suggest help option along with unknown command error ([#1179]) - -### Changed - -* TypeScript fluent return types changed to be more subclass friendly, return `this` rather than `Command` ([#1180]) -* `.parseAsync` returns `Promise` to be consistent with `.parse()` ([#1180]) - -## [5.0.0-1] (2020-02-08) - -### Added - -* `.helpInformation()` returns help text as a string, previously a private routine ([#1169]) -* `.parse()` implicitly uses `process.argv` if arguments not specified ([#1172]) -* optionally specify where `.parse()` arguments "from", if not following node conventions ([#512] [#1172]) - -### Changed - -* changes to error handling ([#1165]) - * throw for author error, not just display message - * preflight for variadic error - * add tips to missing subcommand executable -* update dependencies - -## [5.0.0-0] (2020-02-02) +## [5.0.0] (2020-03-14) ### Added @@ -60,6 +20,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * display help for missing subcommand, by default ([#1088] [#1149]) * combined short options as single argument may include boolean flags and value flag and value (e.g. `-a -b -p 80` can be written as `-abp80`) ([#1145]) * `.parseOption()` includes short flag and long flag expansions ([#1145]) +* `.helpInformation()` returns help text as a string, previously a private routine ([#1169]) +* `.parse()` implicitly uses `process.argv` if arguments not specified ([#1172]) +* optionally specify where `.parse()` arguments "from", if not following node conventions ([#512] [#1172]) +* suggest help option along with unknown command error ([#1179]) +* TypeScript definition for `commands` property of `Command` ([#1184]) +* export `program` property ([#1195]) +* `createCommand` factory method to simplify subclassing ([#1191]) ### Fixed @@ -86,6 +53,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * *Breaking* `.on('command:*', callback)` and other command events passed (changed) results from `.parseOptions`, i.e. operands and unknown ([#1138]) * refactor Option from prototype to class ([#1133]) * refactor Command from prototype to class ([#1159]) +* changes to error handling ([#1165]) + * throw for author error, not just display message + * preflight for variadic error + * add tips to missing subcommand executable +* TypeScript fluent return types changed to be more subclass friendly, return `this` rather than `Command` ([#1180]) +* `.parseAsync` returns `Promise` to be consistent with `.parse()` ([#1180]) +* update dependencies ### Removed @@ -101,6 +75,26 @@ If you use `program.args` or more complicated tests to detect a missing subcomma If you use `.command('*')` to add a default command, you may be be able to switch to `isDefault:true` with a named command. +## [5.0.0-4] (2020-03-03) + +(Released in 5.0.0) + +## [5.0.0-3] (2020-02-20) + +(Released in 5.0.0) + +## [5.0.0-2] (2020-02-10) + +(Released in 5.0.0) + +## [5.0.0-1] (2020-02-08) + +(Released in 5.0.0) + +## [5.0.0-0] (2020-02-02) + +(Released in 5.0.0) + ## [4.1.1] (2020-02-02) ### Fixed @@ -343,6 +337,7 @@ program [#1195]: https://github.com/tj/commander.js/pull/1195 [Unreleased]: https://github.com/tj/commander.js/compare/master...develop +[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 [5.0.0-3]: https://github.com/tj/commander.js/compare/v5.0.0-2..v5.0.0-3 [5.0.0-2]: https://github.com/tj/commander.js/compare/v5.0.0-1..v5.0.0-2 diff --git a/Readme_zh-CN.md b/Readme_zh-CN.md index 6bca81a55..7658574b0 100644 --- a/Readme_zh-CN.md +++ b/Readme_zh-CN.md @@ -11,7 +11,7 @@ - [Commander.js](#commanderjs) - [安装](#%e5%ae%89%e8%a3%85) - - [声明_program_变量](#%e5%a3%b0%e6%98%8eprogram%e5%8f%98%e9%87%8f) + - [声明program变量](#%e5%a3%b0%e6%98%8eprogram%e5%8f%98%e9%87%8f) - [选项](#%e9%80%89%e9%a1%b9) - [常用选项类型,boolean和值](#%e5%b8%b8%e7%94%a8%e9%80%89%e9%a1%b9%e7%b1%bb%e5%9e%8bboolean%e5%92%8c%e5%80%bc) - [默认选项值](#%e9%bb%98%e8%ae%a4%e9%80%89%e9%a1%b9%e5%80%bc) @@ -22,7 +22,7 @@ - [Commands](#commands) - [指定参数语法](#%e6%8c%87%e5%ae%9a%e5%8f%82%e6%95%b0%e8%af%ad%e6%b3%95) - [操作处理程序(Action handler) (子)命令](#%e6%93%8d%e4%bd%9c%e5%a4%84%e7%90%86%e7%a8%8b%e5%ba%8faction-handler-%e5%ad%90%e5%91%bd%e4%bb%a4) - - [独立的可执行子命令](#%e7%8b%ac%e7%ab%8b%e7%9a%84%e5%8f%af%e6%89%a7%e8%a1%8c%e5%ad%90%e5%91%bd%e4%bb%a4) + - [独立的可执行(子)命令](#%e7%8b%ac%e7%ab%8b%e7%9a%84%e5%8f%af%e6%89%a7%e8%a1%8c%e5%ad%90%e5%91%bd%e4%bb%a4) - [自动化帮助信息 help](#%e8%87%aa%e5%8a%a8%e5%8c%96%e5%b8%ae%e5%8a%a9%e4%bf%a1%e6%81%af-help) - [自定义帮助](#%e8%87%aa%e5%ae%9a%e4%b9%89%e5%b8%ae%e5%8a%a9) - [.usage 和 .name](#usage-%e5%92%8c-name) @@ -33,11 +33,11 @@ - [.addHelpCommand()](#addhelpcommand) - [自定义事件监听](#%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6%e7%9b%91%e5%90%ac) - [零碎知识](#%e9%9b%b6%e7%a2%8e%e7%9f%a5%e8%af%86) - - [.parse() and .parseAsync()](#parse-%e5%92%8c-parseasync) + - [.parse() 和 .parseAsync()](#parse-%e5%92%8c-parseasync) - [避免选项命名冲突](#%e9%81%bf%e5%85%8d%e9%80%89%e9%a1%b9%e5%91%bd%e5%90%8d%e5%86%b2%e7%aa%81) - [TypeScript](#typescript) - [Node 选项例如 `--harmony`](#node-%e9%80%89%e9%a1%b9%e4%be%8b%e5%a6%82---harmony) - - [Debugging stand-alone executable subcommands](#%e8%b0%83%e8%af%95%e7%8b%ac%e7%ab%8b%e5%8f%af%e6%89%a7%e8%a1%8c%e5%ad%90%e5%91%bd%e4%bb%a4) + - [调试独立可执行子命令](#%e8%b0%83%e8%af%95%e7%8b%ac%e7%ab%8b%e5%8f%af%e6%89%a7%e8%a1%8c%e5%ad%90%e5%91%bd%e4%bb%a4) - [重载退出(exit)处理](#%e9%87%8d%e8%bd%bd%e9%80%80%e5%87%baexit%e5%a4%84%e7%90%86) - [例子](#%e4%be%8b%e5%ad%90) - [许可证](#%e8%ae%b8%e5%8f%af%e8%af%81) @@ -55,15 +55,15 @@ npm install commander Commander为了方便快速编程导出了一个全局对象。为简洁起见,本README中的示例中使用了它。 ```js -const program = require('commander'); +const { program } = require('commander'); program.version('0.0.1'); ``` 对于可能以多种方式使用commander的大型程序,包括单元测试,最好创建一个本地Command对象来使用。 ```js -const commander = require('commander'); -const program = new commander.Command(); +const { Command } = require('commander'); +const program = new Command(); program.version('0.0.1'); ``` @@ -87,7 +87,7 @@ program.version('0.0.1'); 最常用的两个选项类型是boolean(选项后面不跟值)和选项跟一个值(使用尖括号声明)。除非在命令行中指定,否则两者都是`undefined`。 ```js -const program = require('commander'); +const { program } = require('commander'); program .option('-d, --debug', 'output extra debugging') diff --git a/package-lock.json b/package-lock.json index fa5f4a5e5..839c56fe5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "commander", - "version": "5.0.0-4", + "version": "5.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 26156b832..fc5cdd9f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "commander", - "version": "5.0.0-4", + "version": "5.0.0", "description": "the complete solution for node.js command-line programs", "keywords": [ "commander",