@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
55 lines • 2.78 kB
TypeScript
import { FlagView } from '../../spec/flag_view.ts';
import { LineFacts, PathSpec, type StatFn, type ReaddirFn, type ReadStreamFn } from '../../../types.ts';
import type { CommandFnResult, Context } from '../../config.ts';
import { type GrepFlags } from '../grep_binary.ts';
import type { LineRegex } from '../../../rs/regex.ts';
/**
* What grep's scan reads: the binary-files mode, the context lengths (-C
* filling a side -A or -B left unset), the directory action, whether -D skips
* devices, and the max count (null for no limit, filled only by `maxCount`).
* Mirrors Python's `GrepValues`.
*/
export interface GrepValues {
readonly binary_mode: string;
readonly after_context: number | null;
readonly before_context: number | null;
readonly directories: string;
readonly skip_devices: boolean;
readonly max_count: number | null;
}
/**
* grep's option values but -m, read by mirage-rs in a fixed order; throws
* UsageError for the first value grep refuses, in its words. Mirrors
* Python's `scan_values`.
*/
export declare function scanValues(fl: FlagView): GrepValues;
/**
* -m as mirage-rs reads it, null for no limit; grep checks it after the
* matchers, so a bad count yields to conflicting ones. Throws UsageError
* with grep's refusal. Mirrors Python's `max_count`.
*/
export declare function maxCount(fl: FlagView): number | null;
/**
* Whether grep walks the directories it meets: -r, -R or a -d naming
* recurse, the last of the three on the line winning (grep 3.11). A -d word
* is read by the scan the handler reads (`scanValues`), so the gate and the
* run share it; a line that scan refuses walks nothing, since grep refuses
* it before reading a file. Mirrors Python's `recurses`.
*/
export declare function recurses(fl: FlagView): boolean;
/**
* What grep warns once for the line, before it reads a file: an obsolete -u,
* then the pattern's compile-time warnings. Mirrors Python's `line_warnings`.
*/
export declare function lineWarnings(fl: FlagView, matcher: LineRegex | null): string;
/** The winning filename flag: true for -H, false for -h, null for neither. */
export declare function listingMode(fl: FlagView): [boolean, boolean];
export declare function filenameMode(fl: FlagView): boolean | null;
export declare function parseFlags(fl: FlagView): GrepFlags;
export declare function grepGeneric(name: string, paths: PathSpec[], texts: string[], ctx: Context, stat: StatFn, readdir: ReaddirFn, stream: ReadStreamFn): Promise<CommandFnResult>;
/**
* A grep line walks, and reads, below the directories it names when it
* recurses (`recurses`). Mirrors Python's `facts`.
*/
export declare function facts(fl: FlagView, _operands: readonly (string | PathSpec)[]): LineFacts;
//# sourceMappingURL=grep.d.ts.map