File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2058,7 +2058,16 @@ export class YargsInstance {
20582058 this . #isGlobalContext = false ;
20592059
20602060 const handlerKeys = this . #command. getCommands ( ) ;
2061- const requestCompletions = this . #completion! . completionKey in argv ;
2061+
2062+ const requestCompletions = this . #completion?. completionKey
2063+ ? [
2064+ this . #completion?. completionKey ,
2065+ ...( this . getAliases ( ) [ this . #completion?. completionKey ] ?? [ ] ) ,
2066+ ] . some ( ( key : string ) =>
2067+ Object . prototype . hasOwnProperty . call ( argv , key )
2068+ )
2069+ : false ;
2070+
20622071 const skipRecommendation = helpOptSet || requestCompletions || helpOnly ;
20632072 if ( argv . _ . length ) {
20642073 if ( handlerKeys . length ) {
Original file line number Diff line number Diff line change @@ -1189,4 +1189,26 @@ describe('Completion', () => {
11891189 } ) ;
11901190 } ) ;
11911191 } ) ;
1192+
1193+ describe ( 'parser-configuration' , ( ) => {
1194+ const configurations = [
1195+ { 'strip-dashed' : true } ,
1196+ { 'camel-case-expansion' : true , 'strip-aliased' : true } ,
1197+ ] ;
1198+
1199+ for ( const configuration of configurations ) {
1200+ it ( `should support ${ Object . keys ( configuration ) . join ( ' ' ) } ` , ( ) => {
1201+ process . env . SHELL = '/bin/bash' ;
1202+
1203+ const r = checkOutput (
1204+ ( ) =>
1205+ yargs ( [ '--get-yargs-completions' , 'a' ] )
1206+ . parserConfiguration ( configuration )
1207+ . command ( 'apple' , 'banana' ) . argv
1208+ ) ;
1209+
1210+ r . logs . should . include ( 'apple' ) ;
1211+ } ) ;
1212+ }
1213+ } ) ;
11921214} ) ;
You can’t perform that action at this time.
0 commit comments