Skip to content

Commit

Permalink
Merge pull request #1026 from abetomo/unify_readme_code_examples_with…
Browse files Browse the repository at this point in the history
…_const

Unify readme code examples with 'const'
  • Loading branch information
abetomo committed Aug 23, 2019
2 parents 3b3d3b5 + e9c24fe commit 1298a79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions Readme.md
Expand Up @@ -289,7 +289,7 @@ program
You use `.arguments` to specify the arguments for the top-level command, and for subcommands they are included in the `.command` call. Angled brackets (e.g. `<required>`) indicate required input. Square brackets (e.g. `[optional]`) indicate optional input.
```js
var program = require('commander');
const program = require('commander');
program
.version('0.1.0')
Expand All @@ -313,7 +313,7 @@ console.log('environment:', envValue || "no environment given");
append `...` to the argument name. For example:
```js
var program = require('commander');
const program = require('commander');
program
.version('0.1.0')
Expand All @@ -339,7 +339,7 @@ The action handler gets passed a parameter for each argument you declared, and o
command object itself. This command argument has the values for the command-specific options added as properties.
```js
var program = require('commander');
const program = require('commander');
program
.command('rm <dir>')
Expand All @@ -365,7 +365,7 @@ You handle the options for an executable (sub)command in the executable, and don
```js
// file: ./examples/pm
var program = require('commander');
const program = require('commander');
program
.version('0.1.0')
Expand Down Expand Up @@ -413,7 +413,7 @@ Options:
```js
#!/usr/bin/env node
var program = require('commander');
const program = require('commander');
program
.version('0.1.0')
Expand Down Expand Up @@ -478,8 +478,8 @@ Optional callback cb allows post-processing of help text before it is displayed.
If you want to display help by default (e.g. if no command was provided), you can use something like:
```js
var program = require('commander');
var colors = require('colors');
const program = require('commander');
const colors = require('colors');
program
.version('0.1.0')
Expand Down Expand Up @@ -557,7 +557,7 @@ the inspector port is incremented by 1 for the spawned subcommand.
## Examples
```js
var program = require('commander');
const program = require('commander');
program
.version('0.1.0')
Expand All @@ -570,7 +570,7 @@ program
.description('run setup commands for all envs')
.option("-s, --setup_mode [mode]", "Which setup mode to use")
.action(function(env, options){
var mode = options.setup_mode || "normal";
const mode = options.setup_mode || "normal";
env = env || 'all';
console.log('setup for %s env(s) with %s mode', env, mode);
});
Expand Down
18 changes: 9 additions & 9 deletions Readme_zh-CN.md
Expand Up @@ -286,7 +286,7 @@ program
你可以通过使用 `.arguments` 来为最顶级命令指定参数,对于子命令来说参数都包括在 `.command` 调用之中了。尖括号(e.g. `<required>`)意味着必须的输入,而方括号(e.g. `[optional]`)则是代表了可选的输入
```js
var program = require('commander');
const program = require('commander');
program
.version('0.1.0')
Expand All @@ -309,7 +309,7 @@ console.log('environment:', envValue || "no environment given");
一个命令有且仅有最后一个参数是可变的,你需要在参数名后加上 `...` 来使它可变,例如
```js
var program = require('commander');
const program = require('commander');
program
.version('0.1.0')
Expand All @@ -334,7 +334,7 @@ program.parse(process.argv);
操作处理程序会接收每一个你声明的参数的变量,和一个额外的参数——这个命令对象自己。这个命令的参数包括添加的命令特定选项的值。
```js
var program = require('commander');
const program = require('commander');
program
.command('rm <dir>')
Expand All @@ -361,7 +361,7 @@ Commander 将会尝试在入口脚本(例如 `./examples/pm`)的目录中搜
```js
// file: ./examples/pm
var program = require('commander');
const program = require('commander');

program
.version('0.1.0')
Expand Down Expand Up @@ -405,7 +405,7 @@ Options:
```js
#!/usr/bin/env node

var program = require('commander');
const program = require('commander');

program
.version('0.0.1')
Expand Down Expand Up @@ -468,8 +468,8 @@ Usage: my-command [global options] command
如果你想显示默认的帮助(例如,如果没有提供命令),你可以使用类似的东西:
```js
var program = require('commander');
var colors = require('colors');
const program = require('commander');
const colors = require('colors');
program
.version('0.1.0')
Expand Down Expand Up @@ -548,7 +548,7 @@ node -r ts-node/register pm.ts
## 例子
```js
var program = require('commander');
const program = require('commander');
program
.version('0.1.0')
Expand All @@ -561,7 +561,7 @@ program
.description('run setup commands for all envs')
.option("-s, --setup_mode [mode]", "Which setup mode to use")
.action(function(env, options){
var mode = options.setup_mode || "normal";
const mode = options.setup_mode || "normal";
env = env || 'all';
console.log('setup for %s env(s) with %s mode', env, mode);
});
Expand Down

0 comments on commit 1298a79

Please sign in to comment.