Skip to content

Commit 2c9051a

Browse files
authored
Update README and examples for allowExcessArguments change (#2266)
1 parent 58c28eb commit 2c9051a

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

Readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ const { program } = require('commander');
7979

8080
program
8181
.option('--first')
82-
.option('-s, --separator <char>');
82+
.option('-s, --separator <char>')
83+
.argument('<string>');
8384

8485
program.parse();
8586

@@ -678,8 +679,7 @@ async function main() {
678679
}
679680
```
680681

681-
A command's options and arguments on the command line are validated when the command is used. Any unknown options or missing arguments will be reported as an error. You can suppress the unknown option checks with `.allowUnknownOption()`. By default, it is not an error to
682-
pass more arguments than declared, but you can make this an error with `.allowExcessArguments(false)`.
682+
A command's options and arguments on the command line are validated when the command is used. Any unknown options or missing arguments or excess arguments will be reported as an error. You can suppress the unknown option check with `.allowUnknownOption()`. You can suppress the excess arguments check with `.allowExcessArguments()`.
683683

684684
### Stand-alone executable (sub)commands
685685

@@ -696,7 +696,7 @@ Example file: [pm](./examples/pm)
696696
program
697697
.name('pm')
698698
.version('0.1.0')
699-
.command('install [name]', 'install one or more packages')
699+
.command('install [package-names...]', 'install one or more packages')
700700
.command('search [query]', 'search with optional query')
701701
.command('update', 'update installed packages', { executableFile: 'myUpdateSubCommand' })
702702
.command('list', 'list packages installed', { isDefault: true });

examples/pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ program
1414
.name('pm')
1515
.version('0.0.1')
1616
.description('Fake package manager')
17-
.command('install [name]', 'install one or more packages')
17+
.command('install [package-names...]', 'install one or more packages')
1818
.alias('i')
1919
.command('search [query]', 'search with optional query')
2020
.alias('s')

examples/pm-install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { Command } = require('commander');
44
const program = new Command();
55

66
program.option('-f, --force', 'force installation');
7+
program.argument('[package-names...]');
78

89
program.parse(process.argv);
910

examples/split.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { program } = require('commander');
22

33
// This is used as an example in the README for the Quick Start.
44

5-
program.option('--first').option('-s, --separator <char>');
5+
program.option('--first').option('-s, --separator <char>').argument('<string>');
66

77
program.parse();
88

0 commit comments

Comments
 (0)