@@ -12,84 +12,84 @@ const shells = ['zsh', 'bash', 'fish', 'powershell'];
1212const cli = cac ( 'tab' ) ;
1313
1414cli
15- . command (
16- '<packageManager> complete' ,
17- 'Process completion requests from shell'
18- )
19- . action ( async ( packageManager ) => {
20- if ( ! packageManagers . includes ( packageManager ) ) {
21- console . error ( `Error: Unsupported package manager "${ packageManager } "` ) ;
22- console . error (
23- `Supported package managers: ${ packageManagers . join ( ', ' ) } `
24- ) ;
25- process . exit ( 1 ) ;
26- }
15+ . command (
16+ '<packageManager> complete' ,
17+ 'Process completion requests from shell'
18+ )
19+ . action ( async ( packageManager ) => {
20+ if ( ! packageManagers . includes ( packageManager ) ) {
21+ console . error ( `Error: Unsupported package manager "${ packageManager } "` ) ;
22+ console . error (
23+ `Supported package managers: ${ packageManagers . join ( ', ' ) } `
24+ ) ;
25+ process . exit ( 1 ) ;
26+ }
2727
28- const dashIndex = process . argv . indexOf ( '--' ) ;
29- if ( dashIndex !== - 1 ) {
30- const completion = new Completion ( ) ;
31- setupCompletionForPackageManager ( packageManager , completion ) ;
32- const toComplete = process . argv . slice ( dashIndex + 1 ) ;
33- await completion . parse ( toComplete ) ;
34- process . exit ( 0 ) ;
35- } else {
36- console . error ( `Error: Expected '--' followed by command to complete` ) ;
37- console . error (
38- `Example: ${ packageManager } exec @bombsh/tab ${ packageManager } complete -- command-to-complete`
39- ) ;
40- process . exit ( 1 ) ;
41- }
42- } ) ;
28+ const dashIndex = process . argv . indexOf ( '--' ) ;
29+ if ( dashIndex !== - 1 ) {
30+ const completion = new Completion ( ) ;
31+ setupCompletionForPackageManager ( packageManager , completion ) ;
32+ const toComplete = process . argv . slice ( dashIndex + 1 ) ;
33+ await completion . parse ( toComplete ) ;
34+ process . exit ( 0 ) ;
35+ } else {
36+ console . error ( `Error: Expected '--' followed by command to complete` ) ;
37+ console . error (
38+ `Example: ${ packageManager } exec @bombsh/tab ${ packageManager } complete -- command-to-complete`
39+ ) ;
40+ process . exit ( 1 ) ;
41+ }
42+ } ) ;
4343
4444cli
45- . command (
46- '<packageManager> <shell>' ,
47- 'Generate shell completion script for a package manager'
48- )
49- . action ( async ( packageManager , shell ) => {
50- if ( shell === 'complete' ) {
51- const dashIndex = process . argv . indexOf ( '--' ) ;
52- if ( dashIndex !== - 1 ) {
53- const completion = new Completion ( ) ;
54- setupCompletionForPackageManager ( packageManager , completion ) ;
55- const toComplete = process . argv . slice ( dashIndex + 1 ) ;
56- await completion . parse ( toComplete ) ;
57- process . exit ( 0 ) ;
58- } else {
59- console . error ( `Error: Expected '--' followed by command to complete` ) ;
60- console . error (
61- `Example: ${ packageManager } exec @bombsh/tab ${ packageManager } complete -- command-to-complete`
62- ) ;
63- process . exit ( 1 ) ;
64- }
65- return ;
66- }
45+ . command (
46+ '<packageManager> <shell>' ,
47+ 'Generate shell completion script for a package manager'
48+ )
49+ . action ( async ( packageManager , shell ) => {
50+ if ( shell === 'complete' ) {
51+ const dashIndex = process . argv . indexOf ( '--' ) ;
52+ if ( dashIndex !== - 1 ) {
53+ const completion = new Completion ( ) ;
54+ setupCompletionForPackageManager ( packageManager , completion ) ;
55+ const toComplete = process . argv . slice ( dashIndex + 1 ) ;
56+ await completion . parse ( toComplete ) ;
57+ process . exit ( 0 ) ;
58+ } else {
59+ console . error ( `Error: Expected '--' followed by command to complete` ) ;
60+ console . error (
61+ `Example: ${ packageManager } exec @bombsh/tab ${ packageManager } complete -- command-to-complete`
62+ ) ;
63+ process . exit ( 1 ) ;
64+ }
65+ return ;
66+ }
6767
68- if ( ! packageManagers . includes ( packageManager ) ) {
69- console . error ( `Error: Unsupported package manager "${ packageManager } "` ) ;
70- console . error (
71- `Supported package managers: ${ packageManagers . join ( ', ' ) } `
72- ) ;
73- process . exit ( 1 ) ;
74- }
68+ if ( ! packageManagers . includes ( packageManager ) ) {
69+ console . error ( `Error: Unsupported package manager "${ packageManager } "` ) ;
70+ console . error (
71+ `Supported package managers: ${ packageManagers . join ( ', ' ) } `
72+ ) ;
73+ process . exit ( 1 ) ;
74+ }
7575
76- if ( ! shells . includes ( shell ) ) {
77- console . error ( `Error: Unsupported shell "${ shell } "` ) ;
78- console . error ( `Supported shells: ${ shells . join ( ', ' ) } ` ) ;
79- process . exit ( 1 ) ;
80- }
76+ if ( ! shells . includes ( shell ) ) {
77+ console . error ( `Error: Unsupported shell "${ shell } "` ) ;
78+ console . error ( `Supported shells: ${ shells . join ( ', ' ) } ` ) ;
79+ process . exit ( 1 ) ;
80+ }
8181
82- generateCompletionScript ( packageManager , shell ) ;
83- } ) ;
82+ generateCompletionScript ( packageManager , shell ) ;
83+ } ) ;
8484
8585const completion = tab ( cli ) ;
8686
8787cli . parse ( ) ;
8888
8989function generateCompletionScript ( packageManager : string , shell : string ) {
90- const name = packageManager ;
91- const executable = process . env . npm_execpath
92- ? `${ packageManager } exec @bombsh/tab ${ packageManager } `
93- : `node ${ process . argv [ 1 ] } ${ packageManager } ` ;
94- script ( shell as any , name , executable ) ;
90+ const name = packageManager ;
91+ const executable = process . env . npm_execpath
92+ ? `${ packageManager } exec @bombsh/tab ${ packageManager } `
93+ : `node ${ process . argv [ 1 ] } ${ packageManager } ` ;
94+ script ( shell as any , name , executable ) ;
9595}
0 commit comments