@@ -177,7 +177,7 @@ export class MassargOption<OptionType extends any = unknown, Args extends ArgsOb
177177 parseDetails ( argv : string [ ] , options : ArgsObject , prefixes : Prefixes ) : ArgvValue < OptionType > {
178178 let input = ''
179179 try {
180- if ( ! this . _match ( argv [ 0 ] , prefixes ) ) {
180+ if ( ! this . isMatch ( argv [ 0 ] , prefixes ) ) {
181181 throw new ParseError ( {
182182 path : [ this . name ] ,
183183 code : 'invalid_option' ,
@@ -207,20 +207,17 @@ export class MassargOption<OptionType extends any = unknown, Args extends ArgsOb
207207 return `--${ this . name } ${ aliases } ${ this . description } `
208208 }
209209
210- _match ( arg : string , prefixes : Prefixes ) : boolean {
210+ /** Returns true if the flag (including any prefixes) matches the name or aliases */
211+ isMatch ( arg : string , prefixes : Prefixes ) : boolean {
211212 const name = MassargOption . findNameInArg ( arg , prefixes )
212213 return name === this . name || this . aliases . includes ( name )
213214 }
214215
215- _isOption ( arg : string , prefixes : Prefixes ) : boolean {
216- return (
217- arg . startsWith ( prefixes . optionPrefix ) ||
218- arg . startsWith ( prefixes . aliasPrefix ) ||
219- arg . startsWith ( prefixes . negateFlagPrefix ) ||
220- arg . startsWith ( prefixes . negateAliasPrefix )
221- )
222- }
223-
216+ /**
217+ * Returns the name of the flag, removing any prefixes. It is discriminate of if the option
218+ * exists, as it is a static method; it only returns the name of the flag if it matches the
219+ * prefixes format.
220+ */
224221 static findNameInArg ( arg : string , prefixes : Prefixes ) : string {
225222 const { optionPrefix, aliasPrefix, negateFlagPrefix, negateAliasPrefix } = prefixes
226223 // negate full prefix
@@ -337,7 +334,7 @@ export class MassargFlag extends MassargOption<boolean> {
337334 received : JSON . stringify ( argv [ 0 ] ) ,
338335 } )
339336 }
340- if ( ! this . _match ( argv [ 0 ] , prefixes ) ) {
337+ if ( ! this . isMatch ( argv [ 0 ] , prefixes ) ) {
341338 throw new ParseError ( {
342339 path : [ this . name ] ,
343340 code : 'invalid_option' ,
0 commit comments