diff --git a/bin/next b/bin/next index e0d4c3e3..b18cae54 100755 --- a/bin/next +++ b/bin/next @@ -6,15 +6,29 @@ import { watchFile } from 'fs' const defaultCommand = 'dev' const commands = new Set([ - defaultCommand, 'init', 'build', - 'start' + 'start', + defaultCommand ]) let cmd = process.argv[2] let args +if (new Set(['--help', '-h']).has(cmd)) { + console.log(` + Usage + $ next + + Available commands + ${Array.from(commands).join(', ')} + + For more information run a command with the --help flag + $ next init --help + `) + process.exit(0) +} + if (commands.has(cmd)) { args = process.argv.slice(3) } else { diff --git a/bin/next-build b/bin/next-build index e9ef694a..4e119889 100755 --- a/bin/next-build +++ b/bin/next-build @@ -11,6 +11,20 @@ const argv = parseArgs(process.argv.slice(2), { boolean: ['h'] }) +if (argv.help) { + console.log(` + Description + Compiles the application for production deployment + + Usage + $ next build + + represents where the compiled .next folder should go. + If no directory is provided, .next will be created in the current directory + `) + process.exit(0) +} + const dir = resolve(argv._[0] || '.') build(dir) diff --git a/bin/next-dev b/bin/next-dev index e66dc94d..748307c7 100755 --- a/bin/next-dev +++ b/bin/next-dev @@ -16,6 +16,25 @@ const argv = parseArgs(process.argv.slice(2), { } }) +if (argv.help) { + console.log(` + Description + Starts the application in development mode (hot-code reloading, error + reporting, etc) + + Usage + $ next dev -p + + represents where the compiled .next folder should go. + If no directory is provided, .next will be created in the current directory + + Options + --port, -p A port number on which to start the application + --help, -p Displays this message + `) + process.exit(0) +} + const dir = resolve(argv._[0] || '.') const srv = new Server({ dir, dev: true }) diff --git a/bin/next-init b/bin/next-init index 37ad31f3..a0938d20 100755 --- a/bin/next-init +++ b/bin/next-init @@ -11,6 +11,23 @@ const argv = parseArgs(process.argv.slice(2), { boolean: ['h'] }) +if (argv.help) { + console.log(` + Description + Scaffolds a simple project structure to get started quickly + + Usage + $ next init + + If no directory is provided the current directory will be used. + + Options + --help, -p Displays this message + `) + + process.exit(0) +} + const dir = resolve(argv._[0] || '.') if (basename(dir) === 'pages') { diff --git a/bin/next-start b/bin/next-start index db5273ee..85d9eb81 100755 --- a/bin/next-start +++ b/bin/next-start @@ -15,6 +15,26 @@ const argv = parseArgs(process.argv.slice(2), { } }) +if (argv.help) { + console.log(` + Description + Starts the application in production mode. + The application should be compiled with \`next build\` first. + + Usage + $ next start -p + + is the directory that contains the compiled .next folder + created by running \`next build\`. + If no directory is provided, the current directory will be assumed. + + Options + --port, -p A port number on which to start the application + --help, -p Displays this message + `) + process.exit(0) +} + const dir = resolve(argv._[0] || '.') const srv = new Server({ dir })