feat(cli): add gemini-auth command and alias support
This commit is contained in:
+25
-3
@@ -27,6 +27,7 @@ import { registerOpenaiAuthCommand } from './openai-auth.js';
|
||||
import { registerOpenaiKeyCommand } from './openai-key.js';
|
||||
import { registerZaiAuthCommand } from './zai-auth.js';
|
||||
import { registerAnthropicAuthCommand } from './anthropic-auth.js';
|
||||
import { registerGeminiAuthCommand } from './gemini-auth.js';
|
||||
import { registerSkillsCommand } from './skills.js';
|
||||
import { registerBackupCommand } from './backup.js';
|
||||
import { registerCompanionCommand } from './companion.js';
|
||||
@@ -57,6 +58,7 @@ export function createProgram(): Command {
|
||||
registerOpenaiKeyCommand(program);
|
||||
registerZaiAuthCommand(program);
|
||||
registerAnthropicAuthCommand(program);
|
||||
registerGeminiAuthCommand(program);
|
||||
registerSkillsCommand(program);
|
||||
registerBackupCommand(program);
|
||||
registerCompanionCommand(program);
|
||||
@@ -80,10 +82,30 @@ function isDirectRun(): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeAliasFlags(argv: string[]): string[] {
|
||||
const aliasMap: Record<string, string> = {
|
||||
'--anthropic-auth': 'anthropic-auth',
|
||||
'--gemini-auth': 'gemini-auth',
|
||||
'--zai-auth': 'zai-auth',
|
||||
'--openai-auth': 'openai-auth',
|
||||
'--openai-key': 'openai-key',
|
||||
};
|
||||
|
||||
for (const [flag, command] of Object.entries(aliasMap)) {
|
||||
if (argv.includes(flag)) {
|
||||
const filtered = argv.filter((arg) => arg !== flag);
|
||||
return [filtered[0] ?? 'node', filtered[1] ?? 'flynn', command, ...filtered.slice(2)];
|
||||
}
|
||||
}
|
||||
|
||||
return argv;
|
||||
}
|
||||
|
||||
if (isDirectRun()) {
|
||||
const program = createProgram();
|
||||
const argv = process.argv.length <= 2
|
||||
? [...process.argv, 'tui']
|
||||
: process.argv;
|
||||
const normalizedArgv = normalizeAliasFlags(process.argv);
|
||||
const argv = normalizedArgv.length <= 2
|
||||
? [...normalizedArgv, 'tui']
|
||||
: normalizedArgv;
|
||||
program.parse(argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user