Skip to content

Commit

Permalink
Update README and examples for allowExcessArguments change (#2266)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn authored Oct 13, 2024
1 parent 58c28eb commit 2c9051a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const { program } = require('commander');

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

program.parse();

Expand Down Expand Up @@ -678,8 +679,7 @@ async function main() {
}
```

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
pass more arguments than declared, but you can make this an error with `.allowExcessArguments(false)`.
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()`.

### Stand-alone executable (sub)commands

Expand All @@ -696,7 +696,7 @@ Example file: [pm](./examples/pm)
program
.name('pm')
.version('0.1.0')
.command('install [name]', 'install one or more packages')
.command('install [package-names...]', 'install one or more packages')
.command('search [query]', 'search with optional query')
.command('update', 'update installed packages', { executableFile: 'myUpdateSubCommand' })
.command('list', 'list packages installed', { isDefault: true });
Expand Down
2 changes: 1 addition & 1 deletion examples/pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program
.name('pm')
.version('0.0.1')
.description('Fake package manager')
.command('install [name]', 'install one or more packages')
.command('install [package-names...]', 'install one or more packages')
.alias('i')
.command('search [query]', 'search with optional query')
.alias('s')
Expand Down
1 change: 1 addition & 0 deletions examples/pm-install
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { Command } = require('commander');
const program = new Command();

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

program.parse(process.argv);

Expand Down
2 changes: 1 addition & 1 deletion examples/split.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { program } = require('commander');

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

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

program.parse();

Expand Down

0 comments on commit 2c9051a

Please sign in to comment.