diff options
| author | Evan Senter <[email protected]> | 2025-04-18 17:06:16 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-18 17:06:16 +0100 |
| commit | cb303514035440b1631964cad5093a4c80cd3e43 (patch) | |
| tree | 22e0fec54cfa795cf92d0a32bceafd0c3270e603 /packages/cli/src/config | |
| parent | b56d9c863982bebe9d22871ea5b927e8eacca862 (diff) | |
Adding a new parameter for model, and updating the default to 2.5 Flash. (#18)
Diffstat (limited to 'packages/cli/src/config')
| -rw-r--r-- | packages/cli/src/config/args.ts | 9 | ||||
| -rw-r--r-- | packages/cli/src/config/globalConfig.ts | 50 |
2 files changed, 59 insertions, 0 deletions
diff --git a/packages/cli/src/config/args.ts b/packages/cli/src/config/args.ts index 7c4ebbc0..f36e7e58 100644 --- a/packages/cli/src/config/args.ts +++ b/packages/cli/src/config/args.ts @@ -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 diff --git a/packages/cli/src/config/globalConfig.ts b/packages/cli/src/config/globalConfig.ts new file mode 100644 index 00000000..2b6ad518 --- /dev/null +++ b/packages/cli/src/config/globalConfig.ts @@ -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; +}
\ No newline at end of file |
