diff --git a/.changeset/tender-turkeys-exist.md b/.changeset/tender-turkeys-exist.md new file mode 100644 index 0000000000..e1242ef884 --- /dev/null +++ b/.changeset/tender-turkeys-exist.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa-oas-cli": patch +--- + +feat(oas:cli): output better error when no command is provided diff --git a/packages/oas/medusa-oas-cli/src/command-client.ts b/packages/oas/medusa-oas-cli/src/command-client.ts index 0ca13dfa61..9a196a30e3 100644 --- a/packages/oas/medusa-oas-cli/src/command-client.ts +++ b/packages/oas/medusa-oas-cli/src/command-client.ts @@ -61,6 +61,7 @@ export function getCommand() { command.addOption(opt) } command.action(async (options) => await execute(options)) + command.showHelpAfterError(true) return command } diff --git a/packages/oas/medusa-oas-cli/src/command-oas.ts b/packages/oas/medusa-oas-cli/src/command-oas.ts index c8ecb8d47c..c3e67e44d6 100644 --- a/packages/oas/medusa-oas-cli/src/command-oas.ts +++ b/packages/oas/medusa-oas-cli/src/command-oas.ts @@ -61,6 +61,7 @@ export function getCommand() { command.addOption(opt) } command.action(async (options) => await execute(options)) + command.showHelpAfterError(true) return command } diff --git a/packages/oas/medusa-oas-cli/src/index.ts b/packages/oas/medusa-oas-cli/src/index.ts index 2235620a64..5baa5aa4d7 100644 --- a/packages/oas/medusa-oas-cli/src/index.ts +++ b/packages/oas/medusa-oas-cli/src/index.ts @@ -5,7 +5,7 @@ import { getCommand as oasGetCommand } from "./command-oas" import { getCommand as clientGetCommand } from "./command-client" const run = async () => { - const program = new Command() + const program = getBaseCommand() /** * Alias to command-oas.ts @@ -23,6 +23,18 @@ const run = async () => { await program.parseAsync() } +export function getBaseCommand() { + const command = new Command() + command.name("medusa-oas") + command.action(async () => { + console.log("No command provided.") + command.outputHelp({ error: true }) + }) + command.showHelpAfterError(true) + command.helpOption(false) + return command +} + void (async () => { await run() })()