@@ -20,11 +20,36 @@ import {
2020// Avoids autoconversion to number of the project name by defining that the args
2121// non associated with an option ( _ ) needs to be parsed as a string. See #4606
2222const argv = minimist < {
23- t ?: string
2423 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+ } )
2630const cwd = process . cwd ( )
2731
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+
2853type ColorFunc = ( str : string | number ) => string
2954type Framework = {
3055 name : string
@@ -251,6 +276,12 @@ async function init() {
251276 const argTargetDir = formatTargetDir ( argv . _ [ 0 ] )
252277 const argTemplate = argv . template || argv . t
253278
279+ const help = argv . help
280+ if ( help ) {
281+ console . log ( helpMessage )
282+ return
283+ }
284+
254285 let targetDir = argTargetDir || defaultTargetDir
255286 const getProjectName = ( ) =>
256287 targetDir === '.' ? path . basename ( path . resolve ( ) ) : targetDir
0 commit comments