diff --git a/packages/playground/cli/src/run-cli.ts b/packages/playground/cli/src/run-cli.ts index 0a79672b13..bc4774dd73 100644 --- a/packages/playground/cli/src/run-cli.ts +++ b/packages/playground/cli/src/run-cli.ts @@ -87,11 +87,17 @@ export async function parseOptionsAndRunCLI(argsToParse: string[]) { */ const yargsObject = yargs(argsToParse) .usage('Usage: wp-playground [options]') - .positional('command', { - describe: 'Command to run', - choices: ['server', 'run-blueprint', 'build-snapshot'] as const, - demandOption: true, - }) + .command('server', 'Start a local WordPress server') + .command( + 'run-blueprint', + 'Execute a Blueprint without starting a server' + ) + .command( + 'build-snapshot', + 'Build a ZIP snapshot of a WordPress site based on a Blueprint' + ) + .demandCommand(1, 'Please specify a command') + .strictCommands() .option('outfile', { describe: 'When building, write to this output file.', type: 'string', @@ -287,6 +293,18 @@ export async function parseOptionsAndRunCLI(argsToParse: string[]) { hidden: true, }) .showHelpOnFail(false) + .fail((msg, err, yargsInstance) => { + if (err) { + throw err; + } + if (msg && msg.includes('Please specify a command')) { + yargsInstance.showHelp(); + console.error('\n' + msg); + process.exit(1); + } + console.error(msg); + process.exit(1); + }) .strictOptions() .check(async (args) => { if (args['skip-wordpress-install'] === true) {