Skip to content

Commit da4d96c

Browse files
committed
allow CODEBUFF_API_KEY env for print mode
1 parent 20304cc commit da4d96c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

npm-app/src/cli.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { homedir } from 'os'
44
import path, { basename, dirname, isAbsolute, parse } from 'path'
55
import * as readline from 'readline'
66

7-
import { ASYNC_AGENTS_ENABLED } from '@codebuff/common/constants'
7+
import {
8+
API_KEY_ENV_VAR,
9+
ASYNC_AGENTS_ENABLED,
10+
} from '@codebuff/common/constants'
811
import { AnalyticsEvent } from '@codebuff/common/constants/analytics-events'
912
import {
1013
getAllAgents,
@@ -624,11 +627,10 @@ export class CLI {
624627

625628
// In print mode, skip greeting and interactive setup
626629
if (this.printMode) {
627-
if (!client.user) {
630+
if (!client.user && !process.env[API_KEY_ENV_VAR]) {
628631
printModeLog({
629632
type: 'error',
630-
message:
631-
'Print mode requires authentication. Please run "codebuff login" first.',
633+
message: `Print mode requires authentication. Please run "codebuff login" or set the ${API_KEY_ENV_VAR} environment variable first.`,
632634
})
633635
process.exit(1)
634636
}

0 commit comments

Comments
 (0)