/** * @file Argument parsing utilities for CLI applications. Wraps the vendored * yargs-parser with a Node.js parseArgs-compatible surface for booleans, * strings, arrays, aliases, defaults, and coercion. */ /** * Yargs parser options interface. */ export interface YargsOptions { boolean?: string[] | undefined; string?: string[] | undefined; array?: string[] | undefined; alias?: Record | undefined; default?: Record | undefined; coerce?: Record unknown> | undefined; 'unknown-options-as-args'?: boolean | undefined; 'parse-numbers'?: boolean | undefined; 'parse-positional-numbers'?: boolean | undefined; 'boolean-negation'?: boolean | undefined; 'halt-at-non-option'?: boolean | undefined; configuration?: Record | undefined; strict?: boolean | undefined; } /** * Yargs parser result interface. */ export interface YargsArguments extends Record { _: string[]; $0?: string | undefined; } /** * Options for configuring argument parsing, similar to Node.js util.parseArgs. */ export interface ParseArgsOptionsConfig { multiple?: boolean | undefined; short?: string | undefined; type?: 'boolean' | 'string' | undefined; default?: unknown | undefined; coerce?: (value: unknown) => unknown | undefined; } /** * Configuration object for parseArgs function, similar to Node.js * util.parseArgs. */ export interface ParseArgsConfig { args?: readonly string[] | undefined; options?: Record | undefined; strict?: boolean | undefined; tokens?: boolean | undefined; allowPositionals?: boolean | undefined; allowNegative?: boolean | undefined; configuration?: Record | undefined; } /** * Result of parsing command-line arguments. */ export interface ParsedArgs> { values: T; positionals: string[]; raw: YargsArguments; } /** * Common parseArgs configuration for Socket registry scripts. * * @unused No internal or Socket consumers; only its unit tests exercise it. */ export declare const commonParseArgsConfig: ParseArgsConfig; /** * Extract positional arguments from getNodeProcess().argv. Useful for commands * that accept file paths or other positional parameters. * * @example * ;```typescript * // process.argv = ["node", "script.js", "src", "lib", "--verbose"] * getPositionalArgs() // ["src", "lib"] * ``` */ export declare function getPositionalArgs(startIndex?: number): string[]; /** * Check if a specific flag is present in argv. * * @example * ;```typescript * hasFlag('verbose') // true if --verbose is in process.argv * hasFlag('force', ['--force', '--quiet']) // true * ``` */ export declare function hasFlag(flag: string, argv?: string[]): boolean; /** * Parse command-line arguments with a Node.js parseArgs-compatible API. Uses * yargs-parser internally for robust argument parsing. * * @example * ;```typescript * const { values, positionals } = parseArgs({ * args: ['--force', '--quiet', 'file.ts'], * options: { * force: { type: 'boolean' }, * quiet: { type: 'boolean', short: 'q' }, * }, * }) * ``` */ export declare function parseArgs>(config?: ParseArgsConfig): ParsedArgs; /** * Parse command-line arguments with Socket defaults. Provides sensible defaults * for Socket CLI applications. * * @example * ;```typescript * const { values, positionals } = parseArgsWithDefaults({ * args: ['--force', 'file.ts'], * options: { force: { type: 'boolean' } }, * }) * ``` */ export declare function parseArgsWithDefaults>(config?: ParseArgsConfig): ParsedArgs;