@@ -75,13 +75,18 @@ async function printVersion() {
75
75
/** Determine which command the user requested */
76
76
function resolveCommand ( flags : Arguments ) : CLICommand {
77
77
const cmd = flags . _ [ 2 ] as string ;
78
- if ( cmd === 'add' ) return 'add' ;
79
- if ( cmd === 'sync' ) return 'sync' ;
80
- if ( cmd === 'telemetry' ) return 'telemetry' ;
81
78
if ( flags . version ) return 'version' ;
82
- else if ( flags . help ) return 'help' ;
83
79
84
- const supportedCommands = new Set ( [ 'dev' , 'build' , 'preview' , 'check' , 'docs' ] ) ;
80
+ const supportedCommands = new Set ( [
81
+ 'add' ,
82
+ 'sync' ,
83
+ 'telemetry' ,
84
+ 'dev' ,
85
+ 'build' ,
86
+ 'preview' ,
87
+ 'check' ,
88
+ 'docs' ,
89
+ ] ) ;
85
90
if ( supportedCommands . has ( cmd ) ) {
86
91
return cmd as CLICommand ;
87
92
}
@@ -144,6 +149,16 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
144
149
}
145
150
case 'docs' : {
146
151
telemetry . record ( event . eventCliSession ( cmd ) ) ;
152
+ if ( flags . help || flags . h ) {
153
+ printHelp ( {
154
+ commandName : 'astro docs' ,
155
+ tables : {
156
+ Flags : [ [ '--help (-h)' , 'See all available flags.' ] ] ,
157
+ } ,
158
+ description : `Launches the Astro Docs website directly from the terminal.` ,
159
+ } ) ;
160
+ return ;
161
+ }
147
162
return await openInBrowser ( 'https://docs.astro.build/' ) ;
148
163
}
149
164
case 'telemetry' : {
@@ -203,26 +218,29 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
203
218
case 'build' : {
204
219
const { default : build } = await import ( '../core/build/index.js' ) ;
205
220
206
- return await build ( settings , { ... flags , logging, telemetry, teardownCompiler : true } ) ;
221
+ return await build ( settings , { flags, logging, telemetry, teardownCompiler : true } ) ;
207
222
}
208
223
209
224
case 'check' : {
210
- const ret = await check ( settings , { logging } ) ;
225
+ const ret = await check ( settings , { logging, flags } ) ;
211
226
return process . exit ( ret ) ;
212
227
}
213
228
214
229
case 'sync' : {
215
230
const { syncCli } = await import ( '../core/sync/index.js' ) ;
216
231
217
- const ret = await syncCli ( settings , { logging, fs } ) ;
232
+ const ret = await syncCli ( settings , { logging, fs, flags } ) ;
218
233
return process . exit ( ret ) ;
219
234
}
220
235
221
236
case 'preview' : {
222
237
const { default : preview } = await import ( '../core/preview/index.js' ) ;
223
238
224
- const server = await preview ( settings , { logging, telemetry } ) ;
225
- return await server . closed ( ) ; // keep alive until the server is closed
239
+ const server = await preview ( settings , { logging, telemetry, flags } ) ;
240
+ if ( server ) {
241
+ return await server . closed ( ) ; // keep alive until the server is closed
242
+ }
243
+ return ;
226
244
}
227
245
}
228
246
0 commit comments