From 2dc8331b59bdbdcef493be5abdb0c2a110e95367 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 23 Jan 2024 10:50:34 -0500 Subject: [PATCH] Give a help message when no db command is provided --- packages/db/src/cli/index.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/db/src/cli/index.ts b/packages/db/src/cli/index.ts index d79df46152..f87e0eb827 100644 --- a/packages/db/src/cli/index.ts +++ b/packages/db/src/cli/index.ts @@ -18,9 +18,28 @@ export async function cli({ flags, config }: { flags: Arguments; config: AstroCo return await verifyCommand({ config, flags }); } default: { - // eslint-disable-next-line no-console - console.error(`Unknown command: ${command}`); + if(command == null) { + // eslint-disable-next-line no-console + console.error(`No command provided. + +${showHelp()}`); + } else { + // eslint-disable-next-line no-console + console.error(`Unknown command: ${command} + +${showHelp()}`); + } return; } } + + function showHelp() { + return `astro db + +Usage: + +astro db sync Creates snapshot based on your schema +astro db push Pushes migrations to Astro Studio +astro db verify Verifies migrations have been pushed and errors if not` + } }