Skip to content

Commit 13f7254

Browse files
committed
feat: Add force option to auth command and rename main command
1 parent 1abca77 commit 13f7254

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

src/auth.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ export async function runAuth(options: RunAuthOptions): Promise<void> {
1616
consola.info("Verbose logging enabled")
1717
}
1818

19-
await setupGitHubToken()
19+
await setupGitHubToken({ force: true })
2020
consola.success("GitHub token written to", PATHS.GITHUB_TOKEN_PATH)
21-
22-
process.exit(0)
2321
}
2422

2523
export const auth = defineCommand({

src/lib/token.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ export const setupCopilotToken = async () => {
3333
}, refreshInterval)
3434
}
3535

36-
export async function setupGitHubToken(): Promise<void> {
36+
interface SetupGitHubTokenOptions {
37+
force?: boolean
38+
}
39+
40+
export async function setupGitHubToken(
41+
options?: SetupGitHubTokenOptions,
42+
): Promise<void> {
3743
try {
3844
const githubToken = await readGithubToken()
3945

40-
if (githubToken) {
46+
if (githubToken && !options?.force) {
4147
state.githubToken = githubToken
4248
await logUser()
4349

src/main.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ export async function runServer(options: RunServerOptions): Promise<void> {
5959
})
6060
}
6161

62-
const main = defineCommand({
62+
const start = defineCommand({
6363
meta: {
64-
name: "copilot-api",
65-
description:
66-
"A wrapper around GitHub Copilot API to make it OpenAI compatible, making it usable for other tools.",
64+
name: "start",
65+
description: "Start the Copilot API server",
6766
},
68-
subCommands: { auth },
6967
args: {
7068
port: {
7169
alias: "p",
@@ -128,4 +126,13 @@ const main = defineCommand({
128126
},
129127
})
130128

129+
const main = defineCommand({
130+
meta: {
131+
name: "copilot-api",
132+
description:
133+
"A wrapper around GitHub Copilot API to make it OpenAI compatible, making it usable for other tools.",
134+
},
135+
subCommands: { auth, start },
136+
})
137+
131138
await runMain(main)

0 commit comments

Comments
 (0)