@@ -201,7 +201,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
201
201
}
202
202
203
203
private async _run ( parseResult : ParseResult ) {
204
- const { values : rawFlags , positionals : rawArgs } = parseResult ;
204
+ const { values : rawFlags , positionals : rawArgs , tokens : rawTokens } = parseResult ;
205
205
206
206
if ( rawFlags . help ) {
207
207
this . ctor . printHelp ( ) ;
@@ -261,7 +261,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
261
261
return ;
262
262
}
263
263
264
- this . _parseFlags ( rawFlags ) ;
264
+ this . _parseFlags ( rawFlags , rawTokens ) ;
265
265
266
266
try {
267
267
await this . run ( ) ;
@@ -326,7 +326,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
326
326
return flagKey ;
327
327
}
328
328
329
- private _parseFlags ( rawFlags : ParseResult [ 'values' ] ) {
329
+ private _parseFlags ( rawFlags : ParseResult [ 'values' ] , rawTokens : ParseResult [ 'tokens' ] ) {
330
330
if ( ! this . ctor . flags ) {
331
331
return ;
332
332
}
@@ -347,6 +347,10 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
347
347
348
348
const camelCasedName = camelCaseString ( baseFlagName ) ;
349
349
350
+ const usedShortFormOfTheFlag = rawTokens . some (
351
+ ( token ) => token . kind === 'option' && token . name === baseFlagName ,
352
+ ) ;
353
+
350
354
if ( builderData . exclusive ?. length ) {
351
355
const existingExclusiveFlags = exclusiveFlagMap . get ( baseFlagName ) ?? new Set ( ) ;
352
356
@@ -409,6 +413,11 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
409
413
rawFlag = rawFlag [ 0 ] ! as string | boolean ;
410
414
}
411
415
416
+ // -i='{"foo":"bar"}'
417
+ if ( usedShortFormOfTheFlag && typeof rawFlag === 'string' && rawFlag . startsWith ( '=' ) ) {
418
+ rawFlag = rawFlag . slice ( 1 ) ;
419
+ }
420
+
412
421
if ( typeof rawFlag !== 'undefined' ) {
413
422
switch ( builderData . flagTag ) {
414
423
case 'boolean' : {
@@ -578,6 +587,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
578
587
allowNegative : true ,
579
588
allowPositionals : true ,
580
589
strict : true ,
590
+ tokens : true ,
581
591
options : {
582
592
help : helpFlagDefinition ,
583
593
} as {
@@ -796,6 +806,7 @@ export async function internalRunCommand<Cmd extends typeof BuiltApifyCommand>(
796
806
const rawObject : ParseResult = {
797
807
positionals : [ ] ,
798
808
values : { } ,
809
+ tokens : [ ] ,
799
810
} ;
800
811
801
812
let positionalIndex = 0 ;
0 commit comments