Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions packages/playground/cli/src/run-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,17 @@ export async function parseOptionsAndRunCLI(argsToParse: string[]) {
*/
const yargsObject = yargs(argsToParse)
.usage('Usage: wp-playground <command> [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',
Expand Down Expand Up @@ -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) {
Expand Down