summaryrefslogtreecommitdiff
path: root/packages/cli/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/config')
-rw-r--r--packages/cli/src/config/args.ts9
-rw-r--r--packages/cli/src/config/globalConfig.ts50
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