Skip to content

Commit fcaf0e6

Browse files
committed
opencode auth login: validation on provider id and better error messages
1 parent 19e259d commit fcaf0e6

File tree

1 file changed

+7
-2
lines changed
  • packages/opencode/src/cli/cmd

1 file changed

+7
-2
lines changed

packages/opencode/src/cli/cmd/auth.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,16 @@ export const AuthLoginCommand = cmd({
7878

7979
if (provider === "other") {
8080
provider = await prompts.text({
81-
message:
82-
"Enter provider - must be package name from https://ai-sdk.dev/providers",
81+
message: "Enter provider id",
82+
validate: (x) =>
83+
x.match(/^[a-z-]+$/) ? undefined : "a-z and hyphens only",
8384
})
85+
if (prompts.isCancel(provider)) throw new UI.CancelledError()
8486
provider = provider.replace(/^@ai-sdk\//, "")
8587
if (prompts.isCancel(provider)) throw new UI.CancelledError()
88+
prompts.log.warn(
89+
`This only stores a credential for ${provider} - you will need configure it in opencode.json, check the docs for examples.`,
90+
)
8691
}
8792

8893
if (provider === "amazon-bedrock") {

0 commit comments

Comments
 (0)