@@ -20,11 +20,36 @@ import {
20
20
// Avoids autoconversion to number of the project name by defining that the args
21
21
// non associated with an option ( _ ) needs to be parsed as a string. See #4606
22
22
const argv = minimist < {
23
- t ?: string
24
23
template ?: string
25
- } > ( process . argv . slice ( 2 ) , { string : [ '_' ] } )
24
+ help ?: boolean
25
+ } > ( process . argv . slice ( 2 ) , {
26
+ default : { help : false } ,
27
+ alias : { h : 'help' , t : 'template' } ,
28
+ string : [ '_' ] ,
29
+ } )
26
30
const cwd = process . cwd ( )
27
31
32
+ // prettier-ignore
33
+ const helpMessage = `\
34
+ Usage: create-vite [OPTION]... [DIRECTORY]
35
+
36
+ Create a new Vite project in JavaScript or TypeScript.
37
+ With no arguments, start the CLI in interactive mode.
38
+
39
+ Options:
40
+ -t, --template NAME use a specific template
41
+
42
+ Available templates:
43
+ ${ yellow ( 'vanilla-ts vanilla' ) }
44
+ ${ green ( 'vue-ts vue' ) }
45
+ ${ cyan ( 'react-ts react' ) }
46
+ ${ cyan ( 'react-swc-ts react-swc' ) }
47
+ ${ magenta ( 'preact-ts preact' ) }
48
+ ${ lightRed ( 'lit-ts lit' ) }
49
+ ${ red ( 'svelte-ts svelte' ) }
50
+ ${ blue ( 'solid-ts solid' ) }
51
+ ${ lightBlue ( 'qwik-ts qwik' ) } `
52
+
28
53
type ColorFunc = ( str : string | number ) => string
29
54
type Framework = {
30
55
name : string
@@ -251,6 +276,12 @@ async function init() {
251
276
const argTargetDir = formatTargetDir ( argv . _ [ 0 ] )
252
277
const argTemplate = argv . template || argv . t
253
278
279
+ const help = argv . help
280
+ if ( help ) {
281
+ console . log ( helpMessage )
282
+ return
283
+ }
284
+
254
285
let targetDir = argTargetDir || defaultTargetDir
255
286
const getProjectName = ( ) =>
256
287
targetDir === '.' ? path . basename ( path . resolve ( ) ) : targetDir
0 commit comments