@@ -42,7 +42,9 @@ export interface FlagData {
4242 ambiguousFlag ?: string ;
4343 ambiguousMessage ?: string ;
4444 unknownOptionSuggestion ?: string ;
45+ shortForm ?: boolean ;
4546}
47+
4648export interface CommandErrorOptions {
4749 code : CommandErrorCode ;
4850 command : typeof BuiltApifyCommand ;
@@ -89,7 +91,7 @@ export class CommandError extends Error {
8991 }
9092
9193 case CommandErrorCode . NODEJS_ERR_PARSE_ARGS_UNKNOWN_OPTION : {
92- const match = / U n k n o w n o p t i o n ' - - (?< optionName > [ a - z A - Z 0 - 9 ] + ) ' \. (?< nodeSuggestion > .* ) / gi. exec (
94+ const match = / U n k n o w n o p t i o n ' - (?< longForm > - ) ? (?< optionName > . + ) ' \. (?< nodeSuggestion > .* ) / gi. exec (
9395 this . message ,
9496 ) ;
9597
@@ -103,6 +105,7 @@ export class CommandError extends Error {
103105 name : match . groups ! . optionName ,
104106 expectsValue : false ,
105107 unknownOptionSuggestion : match . groups ! . nodeSuggestion ,
108+ shortForm : ! match . groups ! . longForm ,
106109 } ;
107110 }
108111
@@ -128,7 +131,9 @@ export class CommandError extends Error {
128131 } ) ;
129132
130133 return [
131- chalk . gray ( `Unknown flag provided: ${ chalk . white . bold ( `--${ flagData . name } ` ) } ` ) ,
134+ chalk . gray (
135+ `Unknown flag provided: ${ chalk . white . bold ( flagData . shortForm ? `-${ flagData . name } ` : `--${ flagData . name } ` ) } ` ,
136+ ) ,
132137 flagData . unknownOptionSuggestion
133138 ? chalk . gray ( ` ${ flagData . unknownOptionSuggestion . trim ( ) } ` )
134139 : null ,
@@ -228,7 +233,7 @@ export class CommandError extends Error {
228233 }
229234
230235 static buildMessageFromFlagData ( flagData : FlagData ) : string {
231- const base = [ `Flag ${ chalk . white . bold ( `--${ flagData . name } ` ) } ` ] ;
236+ const base = [ `Flag ${ chalk . white . bold ( flagData . shortForm ? `- ${ flagData . name } ` : `--${ flagData . name } ` ) } ` ] ;
232237
233238 if ( flagData . ambiguousFlag ) {
234239 base . push ( `is ambiguous (meaning the provided value could be interpreted as a flag too).` ) ;
0 commit comments