Skip to content
Myr

Merge pull request #970 from banli17/update-chinese-readme

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

authored by Tomoaki Abe · committed by GitHub · parents 35dc3a3, 82d9c29 · Browse files · 1 file+38 added−3 removed
This commit

State

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

Trailers

  • docs: ✏️ update chinese readme

Diff stats

1 file+38 added−3 removed

  • other:+38 added−3 removed

1 file+38 added−3 removed

modified:Readme_zh-CN.md+38 added-3 removed
428 unmodified lines
429430 输出帮助信息并立即退出。431 可选的回调可在显示帮助文本后处理。432433## 例子433## 自定义事件监听434435 你可以通过监听命令和选项来执行自定义函数。436437```js438// 当有选项verbose时会执行函数439program.on('option:verbose', function () {440 process.env.VERBOSE = this.verbose;441});442443// 未知命令会报错444program.on('command:*', function () {445 console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));446 process.exit(1);447});448```449450## 零碎知识451452### TypeScript453454包里包含 TypeScript 定义文件,但是需要你自己安装 node types。如:455456```bash457npm install commander458npm install --save-dev @types/node459```460461如果你使用 `ts-node` 和 git风格子命令编写 `.ts` 文件, 你需要使用 node 来执行程序以保证正确执行子命令。如:462463```bash464node -r ts-node/register pm.ts465```466 467 ## 例子468469```js470var program = require('commander');471472program473 .version('0.0.1')
34 unmodified lines
508509program.parse(process.argv);510```511478 更多的 [演示](https://github.com/tj/commander.js/tree/master/examples) 可以在这里找到.512 更多的 [演示](https://github.com/tj/commander.js/tree/master/examples) 可以在这里找到。513514## 许可证515482MIT516[MIT](https://github.com/tj/commander.js/blob/master/LICENSE)517