Adding a new parameter for model, and updating the default to 2.5 Flash. (#18)

This commit is contained in:
Evan Senter
2025-04-18 17:06:16 +01:00
committed by GitHub
parent b56d9c8639
commit cb30351403
7 changed files with 81 additions and 7 deletions

View File

@@ -1,8 +1,11 @@
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';
const DEFAULT_GEMINI_MODEL = 'gemini-2.5-flash-preview-04-17';
export interface CliArgs {
target_dir: string | undefined;
model: string | undefined;
_: (string | number)[]; // Captures positional arguments
// Add other expected args here if needed
// e.g., verbose?: boolean;
@@ -16,6 +19,12 @@ export async function parseArguments(): Promise<CliArgs> {
description:
'The target directory for Gemini operations. Defaults to the current working directory.',
})
.option('model', {
alias: 'm',
type: 'string',
description: `The Gemini model to use. Defaults to ${DEFAULT_GEMINI_MODEL}.`,
default: DEFAULT_GEMINI_MODEL,
})
.help()
.alias('h', 'help')
.strict() // Keep strict mode to error on unknown options

View File

@@ -0,0 +1,50 @@
import { CliArgs } from './args.js'; // Assuming CliArgs contains the needed fields
interface GlobalConfig {
model: string;
// Add other global config values here if needed
// e.g., targetDir?: string;
}
let config: GlobalConfig | null = null;
/**
* Initializes the global configuration. Should only be called once at application startup.
* @param args The parsed command-line arguments.
*/
export function initializeConfig(args: Pick<CliArgs, 'model'>): void {
if (config) {
console.warn('Global configuration already initialized.');
return;
}
if (!args.model) {
// This shouldn't happen if default is set correctly in args.ts
throw new Error('Model not provided during config initialization.');
}
config = {
model: args.model,
// Initialize other config values from args here
};
}
/**
* Retrieves the globally stored configuration.
* Throws an error if the configuration has not been initialized.
* @returns The global configuration object.
*/
export function getConfig(): GlobalConfig {
if (!config) {
throw new Error(
'Global configuration accessed before initialization. Call initializeConfig() first.',
);
}
return config;
}
/**
* Helper function to get the configured Gemini model name.
* @returns The model name string.
*/
export function getModel(): string {
return getConfig().model;
}