Skip to content

Commit 2f4cd3d

Browse files
authored
Use revised terminology (#1362)
1 parent e56fba2 commit 2f4cd3d

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

Readme.md

+22-18
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Read this in other languages: English | [简体中文](./Readme_zh-CN.md)
1515
- [Options](#options)
1616
- [Common option types, boolean and value](#common-option-types-boolean-and-value)
1717
- [Default option value](#default-option-value)
18-
- [Other option types, negatable boolean and flag|value](#other-option-types-negatable-boolean-and-flagvalue)
18+
- [Other option types, negatable boolean and boolean|value](#other-option-types-negatable-boolean-and-booleanvalue)
1919
- [Custom option processing](#custom-option-processing)
2020
- [Required option](#required-option)
2121
- [Variadic option](#variadic-option)
@@ -82,14 +82,13 @@ Multiple short flags may optionally be combined in a single argument following t
8282
For example `-a -b -p 80` may be written as `-ab -p80` or even `-abp80`.
8383

8484
You can use `--` to indicate the end of the options, and any remaining arguments will be used without being interpreted.
85-
This is particularly useful for passing options through to another
86-
command, like: `do -- git --version`.
8785

88-
Options on the command line are not positional, and can be specified before or after other command arguments.
86+
Options on the command line are not positional, and can be specified before or after other arguments.
8987

9088
### Common option types, boolean and value
9189

92-
The two most used option types are a boolean flag, and an option which takes a value (declared using angle brackets). Both are `undefined` unless specified on command line.
90+
The two most used option types are a boolean option, and an option which takes its value
91+
from the following argument (declared with angle brackets like `--expect <value>`). Both are `undefined` unless specified on command line.
9392

9493
Example file: [options-common.js](./examples/options-common.js)
9594

@@ -147,13 +146,13 @@ $ pizza-options --cheese stilton
147146
cheese: stilton
148147
```
149148
150-
### Other option types, negatable boolean and flag|value
149+
### Other option types, negatable boolean and boolean|value
151150
152-
You can specify a boolean option long name with a leading `no-` to set the option value to false when used.
151+
You can define a boolean option long name with a leading `no-` to set the option value to false when used.
153152
Defined alone this also makes the option true by default.
154153
155154
If you define `--foo` first, adding `--no-foo` does not change the default value from what it would
156-
otherwise be. You can specify a default boolean value for a boolean flag and it can be overridden on command line.
155+
otherwise be. You can specify a default boolean value for a boolean option and it can be overridden on command line.
157156
158157
Example file: [options-negatable.js](./examples/options-negatable.js)
159158
@@ -180,9 +179,10 @@ $ pizza-options --no-sauce --no-cheese
180179
You ordered a pizza with no sauce and no cheese
181180
```
182181
183-
You can specify an option which functions as a flag but may also take a value (declared using square brackets).
182+
You can specify an option which may be used as a boolean option but may optionally take an option-argument
183+
(declared with square brackets like `--optional [value]`).
184184
185-
Example file: [options-flag-or-value.js](./examples/options-flag-or-value.js)
185+
Example file: [options-boolean-or-value.js](./examples/options-boolean-or-value.js)
186186
187187
```js
188188
program
@@ -208,12 +208,12 @@ For information about possible ambiguous cases, see [options taking varying argu
208208
209209
### Custom option processing
210210
211-
You may specify a function to do custom processing of option values. The callback function receives two parameters, the user specified value and the
212-
previous value for the option. It returns the new value for the option.
211+
You may specify a function to do custom processing of option-arguments. The callback function receives two parameters,
212+
the user specified option-argument and the previous value for the option. It returns the new value for the option.
213213
214-
This allows you to coerce the option value to the desired type, or accumulate values, or do entirely custom processing.
214+
This allows you to coerce the option-argument to the desired type, or accumulate values, or do entirely custom processing.
215215
216-
You can optionally specify the default/starting value for the option after the function.
216+
You can optionally specify the default/starting value for the option after the function parameter.
217217
218218
Example file: [options-custom-processing.js](./examples/options-custom-processing.js)
219219
@@ -286,7 +286,7 @@ error: required option '-c, --cheese <type>' not specified
286286
### Variadic option
287287
288288
You may make an option variadic by appending `...` to the value placeholder when declaring the option. On the command line you
289-
can then specify multiple option arguments, and the parsed option value will be an array. The extra arguments
289+
can then specify multiple option-arguments, and the parsed option value will be an array. The extra arguments
290290
are read until the first argument starting with a dash. The special argument `--` stops option processing entirely. If a value
291291
is specified in the same argument as the option then no further values are read.
292292
@@ -341,7 +341,7 @@ program.version('0.0.1', '-v, --vers', 'output the current version');
341341
342342
You can specify (sub)commands using `.command()` or `.addCommand()`. There are two ways these can be implemented: using an action handler attached to the command, or as a stand-alone executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)).
343343
344-
In the first parameter to `.command()` you specify the command name and any command arguments. The arguments may be `<required>` or `[optional]`, and the last argument may also be `variadic...`.
344+
In the first parameter to `.command()` you specify the command name and any command-arguments. The arguments may be `<required>` or `[optional]`, and the last argument may also be `variadic...`.
345345
346346
You can use `.addCommand()` to add an already configured subcommand to the program.
347347
@@ -369,11 +369,15 @@ program
369369
.addCommand(build.makeBuildCommand());
370370
```
371371
372-
Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `true` for `opts.hidden` will remove the command from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified ([example](./examples/defaultCommand.js)).
372+
Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `hidden: true` will
373+
remove the command from the generated help output. Specifying `isDefault: true` will run the subcommand if no other
374+
subcommand is specified ([example](./examples/defaultCommand.js)).
373375
374376
### Specify the argument syntax
375377
376-
You use `.arguments` to specify the arguments for the top-level command, and for subcommands they are usually included in the `.command` call. Angled brackets (e.g. `<required>`) indicate required input. Square brackets (e.g. `[optional]`) indicate optional input.
378+
You use `.arguments` to specify the expected command-arguments for the top-level command, and for subcommands they are usually
379+
included in the `.command` call. Angled brackets (e.g. `<required>`) indicate required command-arguments.
380+
Square brackets (e.g. `[optional]`) indicate optional command-arguments.
377381
You can optionally describe the arguments in the help by supplying a hash as second parameter to `.description()`.
378382
379383
Example file: [env](./examples/env)
File renamed without changes.

0 commit comments

Comments
 (0)