Skip to documentation content
Branchcut
Reference

CLI reference

Complete command-line reference for Branchcut 0.3.0.

Usage

branchcut find [OPTIONS] PATTERN [PATH...]
branchcut grep [OPTIONS] PATTERN [PATH...]
branchcut grep [OPTIONS] -e PATTERN... [PATH...]
branchcut [PATTERN|SEARCH]
branchcut [OPTIONS]

Files are the default result type. Hidden paths are excluded, traversal uses adaptive bounded parallelism, and output streams in discovery order unless an option changes that behavior. Limits and per-match execution default to one worker; explicit worker counts can enable parallel limits or execution with an explicit child-job budget.

Command selection

find searches filenames or root-relative paths, and grep searches contents. Both use literal patterns by default. The optional executable supports branchcut-regex find -E PATTERN and branchcut-regex grep -E PATTERN. -F explicitly selects literals. Paths default to the current directory.

branchcut find config src/
branchcut grep TODO src/
branchcut grep -e ERROR -e WARN logs/
branchcut grep -f patterns.txt logs/
branchcut grep ERROR -

grep -e (--regexp) and -f (--pattern-file) supply patterns explicitly. When either is present, all remaining positionals are paths. In grep, positional - reads standard input. find accepts an empty pattern to select all names, for example branchcut find '' src/ --glob '**/*.rs'. Use branchcut grep --help or branchcut find --help for focused help.

Bare branchcut grep and branchcut find retain the original one-word filename shortcut. Use branchcut -- grep find to treat both words as ordinary literal search terms. The legacy flag-based interface remains available, including --content and --regex.

Query inputs

OptionMeaning
--glob PATTERNAdd a positive glob. Repeatable.
--exclude PATTERNAdd an exclusion. Repeatable.
--and TEXTRequire an additional literal search term; repeatable.
--content PATTERN, --grep PATTERNSearch selected regular files. See Content search.
branchcut-regex find -E PATTERN [PATH...]Match a filename regex. --full-path selects slash-separated root-relative paths.
positional globShorthand when the argument contains glob syntax.
positional textLiteral filename containment search; case behavior is controlled by the case-mode options.
--cwd PATHSet the filesystem root. Output remains relative to it.
--search-path PATHAdd another search root, resolved relative to --cwd; repeatable.
--config FILELoad a saved query profile file; its directory is the default query root.
--profile NAMESelect a named profile from --config; the default profile is used when omitted.

In the legacy interface, positional globs cannot be combined with --glob or simple search terms, and positional literal terms cannot be combined with --glob. The find and grep commands accept --glob as a path filter alongside their own patterns.

An unrecognized option is an error. Put -- before a literal term that begins with -; remaining arguments are treated as literal search terms. Those terms still cannot be combined with explicit globs.

Filters

OptionMeaning
--extension EXTMatch an extension; repeatable and follows the selected case mode. -e is an extension alias outside grep; within grep, -e adds a content pattern.
--type TYPESelect file (default), dir, symlink, socket, fifo, block-device, or char-device; repeatable. Aliases include f, d, l, s, p, b, and c.
--hiddenInclude hidden path components.
--emptySelect empty files or directories.
--executableSelect executable regular files.
--owner UID[:GID]Filter by numeric user and optional group ID; Unix only.
--gitignoreApply Git ignore sources, including hierarchical .gitignore and repository/global excludes.
--ignoreApply the Git ignore sources plus hierarchical .ignore files.
--ignore-file FILEAdd an explicit Git-style ignore file; repeatable and highest priority.
-i, --ignore-caseASCII-insensitive matching for patterns, terms, and extensions.
-s, --case-sensitiveCase-sensitive matching; this is the default.
--smart-caseASCII-insensitive unless a positive pattern or literal search term contains uppercase ASCII. Exclusions do not change the decision.
--full-pathMatch literal search terms against the cwd-relative path. Glob behavior is unchanged.
--filenameMatch literal search terms against the entry name (default).
--size EXPRFilter regular files by size; repeatable and ANDed. See everyday search.
--modified-within AGEInclude entries with mtime greater than or equal to now - AGE.
--modified-before WHENInclude entries with mtime strictly earlier than an age cutoff, UTC/RFC3339 timestamp, or Unix @seconds instant.
--min-depth NRequire result depth at least N; cwd is depth 0.
--max-depth N|noneRequire result depth at most N; none clears a profile bound.
--followFollow directory symlinks with cycle detection; selects sequential traversal.
--one-file-systemDo not descend across device boundaries; currently Unix only.
--max-open NLimit open directory handles; spilled entries are held in memory and buffered frames resume later.
--contents-firstEmit matching directories after descendants; selects sequential traversal.
--escaped-globsTreat backslashes as pattern escapes instead of Windows path separators.

Different case-mode options cannot be combined. By default, wildcard matching is byte-oriented and case folding is ASCII-only; non-ASCII bytes are exact. --unicode opts valid UTF-8 names into Unicode scalar wildcard matching and simple lowercase case matching. It does not perform full Unicode case folding, normalization, or grapheme matching; invalid native byte names fall back to byte matching. Ignore-file rules are case-sensitive regardless of these options. Case-insensitive mode searches from cwd because literal-prefix root narrowing could miss differently cased directory names on case-sensitive filesystems. On Windows, full-path literal matching treats either slash form as a separator; emitted paths retain native spelling.

Saved profiles use an explicit --config FILE path and independent named sections; see Saved project queries. Profile query options are loaded first. Command-line scalar options override the profile, and repeatable query options append. Output and execution behavior stays on the command line.

Size expressions use a number, optionally prefixed by >, >=, <, <=, or =; a bare number means equality. Decimal fractions are calculated exactly, without floating-point rounding, and are accepted only when unit conversion gives a whole-byte threshold (1.5MiB is valid; 0.1B is rejected). B, K, M, G, T, kB, KB, MB, GB, and TB use decimal powers of 1000. KiB, MiB, GiB, and TiB use powers of 1024. Repeating --size combines conditions with AND.

Durations are a whole number followed by ms, s, m, h, d, or w; zero is allowed, and months/years are not. Each execution captures one clock value for all relative time checks. --modified-within includes the exact boundary and permits future timestamps; --modified-before excludes the exact boundary. Absolute forms are UTC YYYY-MM-DD, YYYY-MM-DDTHH:MM:SSZ, RFC3339 timestamps with numeric ±HH:MM offsets and up to nine fractional-second digits, or Unix seconds prefixed by @ (for example @1735689600.25 or @-0.5). Calendar date forms are limited to years 1970–9999; Unix seconds may be before the epoch if representable by the platform.

Metadata predicates run after type, name, extension, and glob checks and share one metadata fetch. If no metadata filter is requested, entries avoid per-entry metadata calls. Size selection requires --type file. Modification-time checks use the entry itself (including a symlink's own timestamp); directory timestamps never prune descendants.

Type aliases f, d, directory, l, and link are accepted.

Content reads apply only to selected regular files. Globs, exclusions, ignore rules, name/extension/type filters, sizes, and time filters decide which files reach the scanner. The content search and regex guide defines encodings, inputs, schemas, byte offsets, limits, and examples.

OptionMeaning
PATTERNPositional literal pattern for grep.
-e PATTERN, --regexp PATTERNAdd a pattern. Repeatable. Remaining positionals are paths.
-f FILE, --pattern-file FILEAdd UTF-8 patterns, one per line. Remaining positionals are paths.
-E, --regexInterpret patterns as Rust regexes in branchcut-regex.
-F, --fixed-stringsInterpret patterns literally. Default.
--content-mode any|all|noneSelect lines matching any pattern, every pattern, or no pattern.
-w, --word-regexpRequire word boundaries. Also works with literal patterns.
-x, --line-regexpRequire whole-line matches.
-v, --invert-matchInvert final line selection.
-A N, --after-context NAdd following context lines.
-B N, --before-context NAdd preceding context lines.
-C N, --context NAdd context on both sides.
-o, --only-matchingEmit each nonempty matched span.
-l, --files-with-matchesEmit files containing a selected line.
-L, --files-without-matchEmit scanned text files with no selected lines.
-c, --count-per-fileEmit path:count, including zero counts.
--encoding NAMEauto, utf-8, utf-16le, utf-16be, latin1, windows-1252, or raw.
-a, --textDisable the bounded binary skip.
--max-line-bytes NMaximum decoded line length. Default 8 MiB, maximum 64 MiB.
Positional -Search standard input with grep.
Positional PATHAdd a file or directory input with find or grep.
--paths-from FILERead newline-delimited paths. - reads the list from stdin.
--paths-from0 FILERead NUL-delimited paths. - reads the list from stdin.
--preprocess PROGRAMSearch stdout from an executable invoked for each selected file.
--decompressUse external gzip, bzip2, xz, or zstd tools for supported compressed extensions.
--output FORMATContent text, jsonl, json, csv, or tsv.
--explain-matchesAdd path-selection reasons to result records.
--summaryAdd totals to structured output or to stderr in text mode.

The ordinary CLI uses literal matching. Build the optional regex executable from a checkout with cargo install --locked --path integrations/content-regex. branchcut-regex find -E PATTERN selects names or paths, while branchcut-regex grep -E PATTERN selects content lines. The integration has its own declared dependency graph.

Line numbers and columns are one-based. Columns count decoded UTF-8 bytes. Structured byte_offset and spans are zero-based decoded byte coordinates after BOM removal, and span ends are exclusive. --json aliases JSONL in content mode. --json-metadata adds file facts to JSON/JSONL records. --format accepts content fields including {path}, {line}, {column}, {text}, and {spans}.

--count counts selected lines. --first/--limit count lines, or files with -l/-L. Context and repeated spans do not increase the count. Sorted content mode collects candidate paths, sorts them, and then scans contents. Limited content scans use sequential scanning for exact termination. File-list modes support --print0. Content search rejects command execution and preview. Context and span-only output cannot be combined with file/count/quiet modes, and context cannot be combined with span-only output. Per-file count requires unrestricted text output.

Termination and execution

OptionMeaning
--firstStop after the first discovered match.
--limit NStop after N discovered matches; with sorting, select the first N in global order. N must be greater than zero.
--threads NSelect workers explicitly. 1 is sequential; 0 requests up to 16 available workers. The default adapts to the query.
--exec COMMANDExecute an argv template once per match; {} inserts the path.
--exec-jobs NBound child-process concurrency; from 1 to 64.

Explicit worker counts support --limit and --first with exact coordinator cancellation; the selected paths are unordered unless sorted. Per-match execution with explicit parallel workers also requires an explicit --exec-jobs budget. Without an explicit worker count, limits and per-match execution use one worker.

Output

OptionMeaning
-a, --textRead binary-looking files as text during grep search instead of skipping them.
-l, --files-with-matchesWith grep, print each matching path once instead of matching lines.
--sortGlobal native-path order; sorted limits retain at most N paths while scanning all candidates.
--countPrint only the match count.
--jsonEmit one JSON object per line.
--json-metadataAdd entry type, size, readonly state, and modification time to JSON Lines.
-0, --print0Terminate native path output with NUL bytes; incompatible with --json and --count.
--absoluteEmit and execute paths rooted at the resolved --cwd.
--format TEMPLATEFormat each path using the documented path placeholders.
--color WHEN, --hyperlink WHENControl plain-output decoration: auto, always, or never.
--statsWrite traversal counters to standard error.
--strictReturn an error if any filesystem entry cannot be read.
--exec COMMANDExecute an argv template once per match; {} inserts one path.
--exec-batch COMMANDExecute an argv template for bounded path batches; exactly one whole {} argument is required.
--batch-size NSet the maximum paths per batch; defaults to 128 and requires --exec-batch.
--exec-jobs NLimit concurrent child commands to 1–64.
--exec-previewPrint command argv as JSON Lines without launching child processes.

Diagnostics

OptionMeaning
--explainPrint the compiled plan without traversing.
--why PATHExplain one cwd-relative candidate against the query without traversing unrelated directories.
-q, --quietPrint no paths and return success if any match is found.
--format TEMPLATEFormat paths using {}, {/}, {//}, {.}, or {/.}.
--color WHEN, --hyperlink WHENSet plain-output decoration to auto, always, or never.
--completions SHELLPrint completion definitions for bash, zsh, fish, or PowerShell.
-h, --helpPrint help.
--versionPrint the package version.

--why reports MATCHED or EXCLUDED followed by PASS, FAIL, and SKIP checks. When ignore processing is enabled, the decisive ignore rule includes its source path and line. --explain and --why cannot be combined.

Option interaction summary

streaming sequential ── supports first / limit / exec
          │
          ├── + sort ── scan all; retain N if limited, otherwise collect all
          │
          └── adaptive workers ── bounded stream; explicit parallel limits and budgeted execution

Batch execution is also compatible with sorting. The command runner uses native path arguments and applies a 28 KiB command-size budget in addition to --batch-size. --exec-preview displays the planned argv but does not run it.

On this page