Skip to content
Myr

Prepare for 5.0.0 (#1211)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Update version and CHANGELOG for 5.0.0 * Update require style * Set approximate release date

authored by John Gee · committed by GitHub · parent f14df07 · Browse files · 4 files+46 added−51 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+46 added−51 removed

  • other:+46 added−51 removed

4 files+46 added−51 removed

modified:CHANGELOG.md+36 added-41 removed
5 unmodified lines
6and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). (Format adopted after v3.0.0.)78<!-- markdownlint-disable MD024 -->910## [5.0.0-4] (2020-03-03)10## [5.0.0] (2020-03-14)1112### Added1314* `createCommand` factory method to simplify subclassing ([#1191])1516## [5.0.0-3] (2020-02-20)1718### Added1920* TypeScript definition for `commands` property of `Command` ([#1184])21* export `program` property ([#1195])2223## [5.0.0-2] (2020-02-10)2425### Added2627* suggest help option along with unknown command error ([#1179])2829### Changed3031* TypeScript fluent return types changed to be more subclass friendly, return `this` rather than `Command` ([#1180])32* `.parseAsync` returns `Promise<this>` to be consistent with `.parse()` ([#1180])3334## [5.0.0-1] (2020-02-08)3536### Added3738* `.helpInformation()` returns help text as a string, previously a private routine ([#1169])39* `.parse()` implicitly uses `process.argv` if arguments not specified ([#1172])40* optionally specify where `.parse()` arguments "from", if not following node conventions ([#512] [#1172])4142### Changed4344* changes to error handling ([#1165])45 * throw for author error, not just display message46 * preflight for variadic error47 * add tips to missing subcommand executable48* update dependencies4950## [5.0.0-0] (2020-02-02)5152### Added5314* support for nested commands with action-handlers ([#1] [#764] [#1149])15* `.addCommand()` for adding a separately configured command ([#764] [#1149])16* allow a non-executable to be set as the default command ([#742] [#1149])17* implicit help command when there are subcommands (previously only if executables) ([#1149])
1 unmodified line
19* display error message for unknown subcommand, by default ([#432] [#1088] [#1149])20* display help for missing subcommand, by default ([#1088] [#1149])21* 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])22* `.parseOption()` includes short flag and long flag expansions ([#1145])23* `.helpInformation()` returns help text as a string, previously a private routine ([#1169])24* `.parse()` implicitly uses `process.argv` if arguments not specified ([#1172])25* optionally specify where `.parse()` arguments "from", if not following node conventions ([#512] [#1172])26* suggest help option along with unknown command error ([#1179])27* TypeScript definition for `commands` property of `Command` ([#1184])28* export `program` property ([#1195])29* `createCommand` factory method to simplify subclassing ([#1191])3031### Fixed3233* preserve argument order in subcommands ([#508] [#962] [#1138])
18 unmodified lines
52 * `unknown` in returned result has arguments after first unknown option including operands, not just options and values53* *Breaking* `.on('command:*', callback)` and other command events passed (changed) results from `.parseOptions`, i.e. operands and unknown ([#1138])54* refactor Option from prototype to class ([#1133])55* refactor Command from prototype to class ([#1159])56* changes to error handling ([#1165])57 * throw for author error, not just display message58 * preflight for variadic error59 * add tips to missing subcommand executable60* TypeScript fluent return types changed to be more subclass friendly, return `this` rather than `Command` ([#1180])61* `.parseAsync` returns `Promise<this>` to be consistent with `.parse()` ([#1180])62* update dependencies6364### Removed6566* removed EventEmitter from TypeScript definition for Command, eliminating implicit peer dependency on `@types/node` ([#1146])
7 unmodified lines
74If you use `program.args` or more complicated tests to detect a missing subcommand, you may be able to delete the code and rely on the default behaviour.7576If you use `.command('*')` to add a default command, you may be be able to switch to `isDefault:true` with a named command.7778## [5.0.0-4] (2020-03-03)7980(Released in 5.0.0)8182## [5.0.0-3] (2020-02-20)8384(Released in 5.0.0)8586## [5.0.0-2] (2020-02-10)8788(Released in 5.0.0)8990## [5.0.0-1] (2020-02-08)9192(Released in 5.0.0)9394## [5.0.0-0] (2020-02-02)9596(Released in 5.0.0)9798## [4.1.1] (2020-02-02)99100### Fixed101
234 unmodified lines
336[#1191]: https://github.com/tj/commander.js/pull/1191337[#1195]: https://github.com/tj/commander.js/pull/1195338339[Unreleased]: https://github.com/tj/commander.js/compare/master...develop340[5.0.0]: https://github.com/tj/commander.js/compare/v4.1.1..v5.0.0341[5.0.0-4]: https://github.com/tj/commander.js/compare/v5.0.0-3..v5.0.0-4342[5.0.0-3]: https://github.com/tj/commander.js/compare/v5.0.0-2..v5.0.0-3343[5.0.0-2]: https://github.com/tj/commander.js/compare/v5.0.0-1..v5.0.0-2344[5.0.0-1]: https://github.com/tj/commander.js/compare/v5.0.0-0..v5.0.0-1
11 unmodified lines
modified:package-lock.json+1 added-1 removed
1{2 "name": "commander",3 "version": "5.0.0-4",3 "version": "5.0.0",4 "lockfileVersion": 1,5 "requires": true,6 "dependencies": {7 "@babel/code-frame": {
6126 unmodified lines
modified:package.json+1 added-1 removed
modified:Readme_zh-CN.md+8 added-8 removed
9 unmodified lines
10用其他语言阅读:[English](./Readme.md) | 简体中文1112- [Commander.js](#commanderjs)13 - [安装](#%e5%ae%89%e8%a3%85)14 - [声明_program_变量](#%e5%a3%b0%e6%98%8eprogram%e5%8f%98%e9%87%8f)14 - [声明program变量](#%e5%a3%b0%e6%98%8eprogram%e5%8f%98%e9%87%8f)15 - [选项](#%e9%80%89%e9%a1%b9)16 - [常用选项类型,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)17 - [默认选项值](#%e9%bb%98%e8%ae%a4%e9%80%89%e9%a1%b9%e5%80%bc)18 - [其他选项类型,可忽略的布尔值和标志值](#%e5%85%b6%e4%bb%96%e9%80%89%e9%a1%b9%e7%b1%bb%e5%9e%8b%e5%8f%af%e5%bf%bd%e7%95%a5%e7%9a%84%e5%b8%83%e5%b0%94%e5%80%bc%e5%92%8c%e6%a0%87%e5%bf%97%e5%80%bc)
2 unmodified lines
21 - [版本选项](#%e7%89%88%e6%9c%ac%e9%80%89%e9%a1%b9)22 - [Commands](#commands)23 - [指定参数语法](#%e6%8c%87%e5%ae%9a%e5%8f%82%e6%95%b0%e8%af%ad%e6%b3%95)24 - [操作处理程序(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)25 - [独立的可执行子命令](#%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)25 - [独立的可执行(子)命令](#%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)26 - [自动化帮助信息 help](#%e8%87%aa%e5%8a%a8%e5%8c%96%e5%b8%ae%e5%8a%a9%e4%bf%a1%e6%81%af-help)27 - [自定义帮助](#%e8%87%aa%e5%ae%9a%e4%b9%89%e5%b8%ae%e5%8a%a9)28 - [.usage 和 .name](#usage-%e5%92%8c-name)29 - [.help(cb)](#helpcb)
2 unmodified lines
32 - [.helpOption(flags, description)](#helpoptionflags-description)33 - [.addHelpCommand()](#addhelpcommand)34 - [自定义事件监听](#%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6%e7%9b%91%e5%90%ac)35 - [零碎知识](#%e9%9b%b6%e7%a2%8e%e7%9f%a5%e8%af%86)36 - [.parse() and .parseAsync()](#parse-%e5%92%8c-parseasync)36 - [.parse() 和 .parseAsync()](#parse-%e5%92%8c-parseasync)37 - [避免选项命名冲突](#%e9%81%bf%e5%85%8d%e9%80%89%e9%a1%b9%e5%91%bd%e5%90%8d%e5%86%b2%e7%aa%81)38 - [TypeScript](#typescript)39 - [Node 选项例如 `--harmony`](#node-%e9%80%89%e9%a1%b9%e4%be%8b%e5%a6%82---harmony)40 - [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)40 - [调试独立可执行子命令](#%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)41 - [重载退出(exit)处理](#%e9%87%8d%e8%bd%bd%e9%80%80%e5%87%baexit%e5%a4%84%e7%90%86)42 - [例子](#%e4%be%8b%e5%ad%90)43 - [许可证](#%e8%ae%b8%e5%8f%af%e8%af%81)44 - [支持](#%e6%94%af%e6%8c%81)
9 unmodified lines
5455Commander为了方便快速编程导出了一个全局对象。为简洁起见,本README中的示例中使用了它。5657```js58const program = require('commander');58const { program } = require('commander');59program.version('0.0.1');60```6162对于可能以多种方式使用commander的大型程序,包括单元测试,最好创建一个本地Command对象来使用。6364```js65const commander = require('commander');66const program = new commander.Command();65const { Command } = require('commander');66const program = new Command();67program.version('0.0.1');68```6970## 选项
15 unmodified lines
8687最常用的两个选项类型是boolean(选项后面不跟值)和选项跟一个值(使用尖括号声明)。除非在命令行中指定,否则两者都是`undefined`。8889 ```js90const program = require('commander');90const { program } = require('commander');9192program93 .option('-d, --debug', 'output extra debugging')94 .option('-s, --small', 'small pizza size')
616 unmodified lines