@@ -92,27 +92,6 @@ runCli(async (agent, args, ctx) => {
9292 return
9393 }
9494
95- // Print ZSH completion script
96- if ( args [ 0 ] === '--completion-zsh' ) {
97- // eslint-disable-next-line no-console
98- console . log ( rawZshCompletionScript )
99- return
100- }
101-
102- // Print Bash completion script
103- if ( args [ 0 ] === '--completion-bash' ) {
104- // eslint-disable-next-line no-console
105- console . log ( rawBashCompletionScript )
106- return
107- }
108-
109- // Print Fish completion script
110- if ( args [ 0 ] === '--completion-fish' ) {
111- // eslint-disable-next-line no-console
112- console . log ( rawFishCompletionScript )
113- return
114- }
115-
11695 // -p is a flag attempt to read scripts from monorepo
11796 if ( args [ 0 ] === '-p' ) {
11897 const raw = await readWorkspaceScripts ( ctx , args )
@@ -145,4 +124,27 @@ runCli(async (agent, args, ctx) => {
145124 }
146125
147126 return parseNr ( agent , args , ctx )
127+ } , {
128+ onBeforeCommand : ( args , ctx ) => {
129+ // Print ZSH completion script.
130+ if ( args [ 0 ] === '--completion-zsh' ) {
131+ // eslint-disable-next-line no-console
132+ console . log ( rawZshCompletionScript )
133+ return ctx . exit ( )
134+ }
135+
136+ // Print Bash completion script
137+ if ( args [ 0 ] === '--completion-bash' ) {
138+ // eslint-disable-next-line no-console
139+ console . log ( rawBashCompletionScript )
140+ return ctx . exit ( )
141+ }
142+
143+ // Print Fish completion script
144+ if ( args [ 0 ] === '--completion-fish' ) {
145+ // eslint-disable-next-line no-console
146+ console . log ( rawFishCompletionScript )
147+ return ctx . exit ( )
148+ }
149+ } ,
148150} )
0 commit comments