Skip to content

Commit

Permalink
Make api key error message better (#10)
Browse files Browse the repository at this point in the history
<img width="679" alt="Screenshot 2024-03-01 at 6 29 05 PM"
src="https://github.com/autoblocksai/cli/assets/7498009/b644078d-6de2-43d2-a04c-9333f6e1b197">
  • Loading branch information
Nicole White authored Mar 5, 2024
1 parent cbbdd4a commit 7fd0951
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ async function latestVersionMiddleware(): Promise<void> {
}
}

// The newline at the top of this message is intentional;
// it gives separation between the error message shown by
// yargs and this one.
const apiKeyMissingErrorMessage = `
Autoblocks API key is required.
Provide it via the AUTOBLOCKS_API_KEY environment variable or the --api-key option.
You can get your API key from https://app.autoblocks.ai/settings/api-keys`;

const parser = yargs(hideBin(process.argv))
.command(
'testing exec',
Expand All @@ -50,7 +59,6 @@ const parser = yargs(hideBin(process.argv))
'Autoblocks API key. Can be set via the AUTOBLOCKS_API_KEY environment variable.',
type: 'string',
default: process.env.AUTOBLOCKS_API_KEY,
demandOption: true,
})
.option('message', {
alias: 'm',
Expand All @@ -68,6 +76,7 @@ const parser = yargs(hideBin(process.argv))
type: 'boolean',
default: false,
})
.demandOption('api-key', apiKeyMissingErrorMessage)
.help();
},
(argv) => {
Expand Down

0 comments on commit 7fd0951

Please sign in to comment.