refactor: consolidate all flags to use hyphens (deprecate underscore flags) (#3541)
This commit is contained in:
parent
2ed1b378cb
commit
27a2d8af14
|
@ -291,13 +291,13 @@ Arguments passed directly when running the CLI can override other configurations
|
||||||
- Enables sandbox mode for this session.
|
- Enables sandbox mode for this session.
|
||||||
- **`--sandbox-image`**:
|
- **`--sandbox-image`**:
|
||||||
- Sets the sandbox image URI.
|
- Sets the sandbox image URI.
|
||||||
- **`--debug_mode`** (**`-d`**):
|
- **`--debug`** (**`-d`**):
|
||||||
- Enables debug mode for this session, providing more verbose output.
|
- Enables debug mode for this session, providing more verbose output.
|
||||||
- **`--all_files`** (**`-a`**):
|
- **`--all-files`** (**`-a`**):
|
||||||
- If set, recursively includes all files within the current directory as context for the prompt.
|
- If set, recursively includes all files within the current directory as context for the prompt.
|
||||||
- **`--help`** (or **`-h`**):
|
- **`--help`** (or **`-h`**):
|
||||||
- Displays help information about command-line arguments.
|
- Displays help information about command-line arguments.
|
||||||
- **`--show_memory_usage`**:
|
- **`--show-memory-usage`**:
|
||||||
- Displays the current memory usage.
|
- Displays the current memory usage.
|
||||||
- **`--yolo`**:
|
- **`--yolo`**:
|
||||||
- Enables YOLO mode, which automatically approves all tool calls.
|
- Enables YOLO mode, which automatically approves all tool calls.
|
||||||
|
|
|
@ -62,8 +62,8 @@ describe('loadCliConfig', () => {
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set showMemoryUsage to true when --memory flag is present', async () => {
|
it('should set showMemoryUsage to true when --show-memory-usage flag is present', async () => {
|
||||||
process.argv = ['node', 'script.js', '--show_memory_usage'];
|
process.argv = ['node', 'script.js', '--show-memory-usage'];
|
||||||
const settings: Settings = {};
|
const settings: Settings = {};
|
||||||
const config = await loadCliConfig(settings, [], 'test-session');
|
const config = await loadCliConfig(settings, [], 'test-session');
|
||||||
expect(config.getShowMemoryUsage()).toBe(true);
|
expect(config.getShowMemoryUsage()).toBe(true);
|
||||||
|
@ -84,7 +84,7 @@ describe('loadCliConfig', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should prioritize CLI flag over settings for showMemoryUsage (CLI true, settings false)', async () => {
|
it('should prioritize CLI flag over settings for showMemoryUsage (CLI true, settings false)', async () => {
|
||||||
process.argv = ['node', 'script.js', '--show_memory_usage'];
|
process.argv = ['node', 'script.js', '--show-memory-usage'];
|
||||||
const settings: Settings = { showMemoryUsage: false };
|
const settings: Settings = { showMemoryUsage: false };
|
||||||
const config = await loadCliConfig(settings, [], 'test-session');
|
const config = await loadCliConfig(settings, [], 'test-session');
|
||||||
expect(config.getShowMemoryUsage()).toBe(true);
|
expect(config.getShowMemoryUsage()).toBe(true);
|
||||||
|
|
|
@ -37,10 +37,12 @@ const logger = {
|
||||||
interface CliArgs {
|
interface CliArgs {
|
||||||
model: string | undefined;
|
model: string | undefined;
|
||||||
sandbox: boolean | string | undefined;
|
sandbox: boolean | string | undefined;
|
||||||
'sandbox-image': string | undefined;
|
sandboxImage: string | undefined;
|
||||||
debug: boolean | undefined;
|
debug: boolean | undefined;
|
||||||
prompt: string | undefined;
|
prompt: string | undefined;
|
||||||
|
allFiles: boolean | undefined;
|
||||||
all_files: boolean | undefined;
|
all_files: boolean | undefined;
|
||||||
|
showMemoryUsage: boolean | undefined;
|
||||||
show_memory_usage: boolean | undefined;
|
show_memory_usage: boolean | undefined;
|
||||||
yolo: boolean | undefined;
|
yolo: boolean | undefined;
|
||||||
telemetry: boolean | undefined;
|
telemetry: boolean | undefined;
|
||||||
|
@ -48,7 +50,7 @@ interface CliArgs {
|
||||||
telemetryTarget: string | undefined;
|
telemetryTarget: string | undefined;
|
||||||
telemetryOtlpEndpoint: string | undefined;
|
telemetryOtlpEndpoint: string | undefined;
|
||||||
telemetryLogPrompts: boolean | undefined;
|
telemetryLogPrompts: boolean | undefined;
|
||||||
'allowed-mcp-server-names': string | undefined;
|
allowedMcpServerNames: string | undefined;
|
||||||
extensions: string[] | undefined;
|
extensions: string[] | undefined;
|
||||||
listExtensions: boolean | undefined;
|
listExtensions: boolean | undefined;
|
||||||
}
|
}
|
||||||
|
@ -86,17 +88,35 @@ async function parseArguments(): Promise<CliArgs> {
|
||||||
description: 'Run in debug mode?',
|
description: 'Run in debug mode?',
|
||||||
default: false,
|
default: false,
|
||||||
})
|
})
|
||||||
.option('all_files', {
|
.option('all-files', {
|
||||||
alias: 'a',
|
alias: ['a'],
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Include ALL files in context?',
|
description: 'Include ALL files in context?',
|
||||||
default: false,
|
default: false,
|
||||||
})
|
})
|
||||||
|
.option('all_files', {
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Include ALL files in context?',
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
.deprecateOption(
|
||||||
|
'all_files',
|
||||||
|
'Use --all-files instead. We will be removing --all_files in the coming weeks.',
|
||||||
|
)
|
||||||
|
.option('show-memory-usage', {
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Show memory usage in status bar',
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
.option('show_memory_usage', {
|
.option('show_memory_usage', {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Show memory usage in status bar',
|
description: 'Show memory usage in status bar',
|
||||||
default: false,
|
default: false,
|
||||||
})
|
})
|
||||||
|
.deprecateOption(
|
||||||
|
'show_memory_usage',
|
||||||
|
'Use --show-memory-usage instead. We will be removing --show_memory_usage in the coming weeks.',
|
||||||
|
)
|
||||||
.option('yolo', {
|
.option('yolo', {
|
||||||
alias: 'y',
|
alias: 'y',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
@ -224,9 +244,9 @@ export async function loadCliConfig(
|
||||||
let mcpServers = mergeMcpServers(settings, activeExtensions);
|
let mcpServers = mergeMcpServers(settings, activeExtensions);
|
||||||
const excludeTools = mergeExcludeTools(settings, activeExtensions);
|
const excludeTools = mergeExcludeTools(settings, activeExtensions);
|
||||||
|
|
||||||
if (argv['allowed-mcp-server-names']) {
|
if (argv.allowedMcpServerNames) {
|
||||||
const allowedNames = new Set(
|
const allowedNames = new Set(
|
||||||
argv['allowed-mcp-server-names'].split(',').filter(Boolean),
|
argv.allowedMcpServerNames.split(',').filter(Boolean),
|
||||||
);
|
);
|
||||||
if (allowedNames.size > 0) {
|
if (allowedNames.size > 0) {
|
||||||
mcpServers = Object.fromEntries(
|
mcpServers = Object.fromEntries(
|
||||||
|
@ -246,7 +266,7 @@ export async function loadCliConfig(
|
||||||
targetDir: process.cwd(),
|
targetDir: process.cwd(),
|
||||||
debugMode,
|
debugMode,
|
||||||
question: argv.prompt || '',
|
question: argv.prompt || '',
|
||||||
fullContext: argv.all_files || false,
|
fullContext: argv.allFiles || argv.all_files || false,
|
||||||
coreTools: settings.coreTools || undefined,
|
coreTools: settings.coreTools || undefined,
|
||||||
excludeTools,
|
excludeTools,
|
||||||
toolDiscoveryCommand: settings.toolDiscoveryCommand,
|
toolDiscoveryCommand: settings.toolDiscoveryCommand,
|
||||||
|
@ -257,7 +277,10 @@ export async function loadCliConfig(
|
||||||
geminiMdFileCount: fileCount,
|
geminiMdFileCount: fileCount,
|
||||||
approvalMode: argv.yolo || false ? ApprovalMode.YOLO : ApprovalMode.DEFAULT,
|
approvalMode: argv.yolo || false ? ApprovalMode.YOLO : ApprovalMode.DEFAULT,
|
||||||
showMemoryUsage:
|
showMemoryUsage:
|
||||||
argv.show_memory_usage || settings.showMemoryUsage || false,
|
argv.showMemoryUsage ||
|
||||||
|
argv.show_memory_usage ||
|
||||||
|
settings.showMemoryUsage ||
|
||||||
|
false,
|
||||||
accessibility: settings.accessibility,
|
accessibility: settings.accessibility,
|
||||||
telemetry: {
|
telemetry: {
|
||||||
enabled: argv.telemetry ?? settings.telemetry?.enabled,
|
enabled: argv.telemetry ?? settings.telemetry?.enabled,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { Settings } from './settings.js';
|
||||||
// to avoid circular dependencies.
|
// to avoid circular dependencies.
|
||||||
interface SandboxCliArgs {
|
interface SandboxCliArgs {
|
||||||
sandbox?: boolean | string;
|
sandbox?: boolean | string;
|
||||||
'sandbox-image'?: string;
|
sandboxImage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VALID_SANDBOX_COMMANDS: ReadonlyArray<SandboxConfig['command']> = [
|
const VALID_SANDBOX_COMMANDS: ReadonlyArray<SandboxConfig['command']> = [
|
||||||
|
@ -99,7 +99,7 @@ export async function loadSandboxConfig(
|
||||||
|
|
||||||
const packageJson = await getPackageJson();
|
const packageJson = await getPackageJson();
|
||||||
const image =
|
const image =
|
||||||
argv['sandbox-image'] ??
|
argv.sandboxImage ??
|
||||||
process.env.GEMINI_SANDBOX_IMAGE ??
|
process.env.GEMINI_SANDBOX_IMAGE ??
|
||||||
packageJson?.config?.sandboxImageUri;
|
packageJson?.config?.sandboxImageUri;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue