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