@@ -119,7 +119,8 @@ function _assignOption(
119
119
ignored : string [ ] ,
120
120
errors : string [ ] ,
121
121
) {
122
- let key = arg . substr ( 2 ) ;
122
+ const from = arg . startsWith ( '--' ) ? 2 : 1 ;
123
+ let key = arg . substr ( from ) ;
123
124
let option : Option | null = null ;
124
125
let value = '' ;
125
126
const i = arg . indexOf ( '=' ) ;
@@ -172,8 +173,9 @@ function _assignOption(
172
173
value = arg . substring ( i + 1 ) ;
173
174
}
174
175
}
176
+
175
177
if ( option === null ) {
176
- if ( args [ 0 ] && ! args [ 0 ] . startsWith ( '-- ' ) ) {
178
+ if ( args [ 0 ] && ! args [ 0 ] . startsWith ( '-' ) ) {
177
179
leftovers . push ( arg , args [ 0 ] ) ;
178
180
args . shift ( ) ;
179
181
} else {
@@ -285,14 +287,14 @@ export function parseArguments(args: string[], options: Option[] | null): Argume
285
287
const flag = arg [ i ] ;
286
288
// If the next character is an '=', treat it as a long flag.
287
289
if ( arg [ i + 1 ] == '=' ) {
288
- const f = '-- ' + flag + arg . slice ( i + 1 ) ;
290
+ const f = '-' + flag + arg . slice ( i + 1 ) ;
289
291
_assignOption ( f , args , options , parsedOptions , positionals , leftovers , ignored , errors ) ;
290
292
break ;
291
293
}
292
294
// Treat the last flag as `--a` (as if full flag but just one letter). We do this in
293
295
// the loop because it saves us a check to see if the arg is just `-`.
294
296
if ( i == arg . length - 1 ) {
295
- const arg = '-- ' + flag ;
297
+ const arg = '-' + flag ;
296
298
_assignOption ( arg , args , options , parsedOptions , positionals , leftovers , ignored , errors ) ;
297
299
} else {
298
300
const maybeOption = _getOptionFromName ( flag , options ) ;
0 commit comments