mirror of
https://github.com/anomalyco/opencode.git
synced 2026-06-01 19:05:38 +00:00
fix(cli): default console login url (#28474)
This commit is contained in:
@@ -15,6 +15,8 @@ const dim = (value: string) => UI.Style.TEXT_DIM + value + UI.Style.TEXT_NORMAL
|
|||||||
|
|
||||||
const activeSuffix = (isActive: boolean) => (isActive ? dim(" (active)") : "")
|
const activeSuffix = (isActive: boolean) => (isActive ? dim(" (active)") : "")
|
||||||
|
|
||||||
|
export const defaultConsoleUrl = "https://console.opencode.ai"
|
||||||
|
|
||||||
export const formatAccountLabel = (account: { email: string; url: string }, isActive: boolean) =>
|
export const formatAccountLabel = (account: { email: string; url: string }, isActive: boolean) =>
|
||||||
`${account.email} ${dim(account.url)}${activeSuffix(isActive)}`
|
`${account.email} ${dim(account.url)}${activeSuffix(isActive)}`
|
||||||
|
|
||||||
@@ -173,18 +175,17 @@ const openEffect = Effect.fn("open")(function* () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const LoginCommand = effectCmd({
|
export const LoginCommand = effectCmd({
|
||||||
command: "login <url>",
|
command: "login [url]",
|
||||||
describe: false,
|
describe: false,
|
||||||
instance: false,
|
instance: false,
|
||||||
builder: (yargs) =>
|
builder: (yargs) =>
|
||||||
yargs.positional("url", {
|
yargs.positional("url", {
|
||||||
describe: "server URL",
|
describe: "server URL",
|
||||||
type: "string",
|
type: "string",
|
||||||
demandOption: true,
|
|
||||||
}),
|
}),
|
||||||
handler: Effect.fn("Cli.account.login")(function* (args) {
|
handler: Effect.fn("Cli.account.login")(function* (args) {
|
||||||
UI.empty()
|
UI.empty()
|
||||||
yield* Effect.orDie(loginEffect(args.url))
|
yield* Effect.orDie(loginEffect(args.url ?? defaultConsoleUrl))
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import { describe, expect, test } from "bun:test"
|
import { describe, expect, test } from "bun:test"
|
||||||
import stripAnsi from "strip-ansi"
|
import stripAnsi from "strip-ansi"
|
||||||
|
|
||||||
import { formatAccountLabel, formatOrgLine } from "../../src/cli/cmd/account"
|
import { defaultConsoleUrl, formatAccountLabel, formatOrgLine } from "../../src/cli/cmd/account"
|
||||||
|
|
||||||
describe("console account display", () => {
|
describe("console account display", () => {
|
||||||
|
test("uses console.opencode.ai as the default login URL", () => {
|
||||||
|
expect(defaultConsoleUrl).toBe("https://console.opencode.ai")
|
||||||
|
})
|
||||||
|
|
||||||
test("includes the account url in account labels", () => {
|
test("includes the account url in account labels", () => {
|
||||||
expect(stripAnsi(formatAccountLabel({ email: "one@example.com", url: "https://one.example.com" }, false))).toBe(
|
expect(stripAnsi(formatAccountLabel({ email: "one@example.com", url: "https://one.example.com" }, false))).toBe(
|
||||||
"one@example.com https://one.example.com",
|
"one@example.com https://one.example.com",
|
||||||
|
|||||||
Reference in New Issue
Block a user