You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,15 @@ const program = new Command();
175
175
176
176
## Options
177
177
178
-
Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|').
178
+
Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|'). To allow a wider range of short-ish flags than just
179
+
single characters, you may also have two long options. Examples:
180
+
181
+
```js
182
+
program
183
+
.option('-p, --port <number>', 'server port number')
184
+
.option('--trace', 'add extra debugging output')
185
+
.option('--ws, --workspace <name>', 'use a custom workspace')
186
+
```
179
187
180
188
The parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler.
-[Short option flag longer than a single character](#short-option-flag-longer-than-a-single-character)
20
20
-[Default import of global Command object](#default-import-of-global-command-object)
21
21
22
22
### RegExp .option() parameter
@@ -168,12 +168,6 @@ function myParseInt(value, dummyPrevious) {
168
168
169
169
Deprecated from Commander v8.
170
170
171
-
### Short option flag longer than a single character
172
-
173
-
Short option flags like `-ws` were never supported, but the old README did not make this clear. The README now states that short options are a single character.
174
-
175
-
README updated in Commander v3. Deprecated from Commander v9.
176
-
177
171
### Import from `commander/esm.mjs`
178
172
179
173
The first support for named imports required an explicit entry file.
### Short option flag longer than a single character
230
+
231
+
Short option flags like `-ws` were never supported, but the old README did not make this clear. The README now states that short options are a single character.
232
+
233
+
- README updated in Commander v3.
234
+
- Deprecated from Commander v9.
235
+
- Throws an exception in Commander v13. Deprecated and gone!
236
+
- Replacement added in Commander v13.1 with support for dual long options, like `--ws, --workspace`.
0 commit comments