/ or -, exactly one argument
each, no bare flags.
/P, which accumulates root paths
in the order given.
/r rejects an empty argument, because the claim that an empty expression matches every line did not hold across engines./ and - are equivalent, so /P and
-P name the same switch. Because letters are case-sensitive,
/h and /H denote different commands./s true rather than /s.true or false, matched
case-insensitively. TRUE, True, and
true are equivalent./P resolves last-wins,
earlier occurrences silently discarded. /P accumulates instead, each
occurrence adding a root path traversed in the order given.main's
char* argv[] and states the ASCII limit that follows on Windows.
| Switch | Argument (default) | Meaning |
|---|---|---|
/P |
path (.) |
Root path for traversal, absolute or relative. Repeat to add more; the paths are traversed in the order given |
/p |
"ext, ext" ("") |
Extensions to search. An empty list searches every file, including files with no extension; a non-empty list excludes files with no extension |
/r |
regex (".") |
Regular expression evaluated against each line, compiled once per invocation. It must not be empty; the default . is the way to match every line |
/s |
bool (true) |
Recursive search. When false, the files directly within the root path are searched but no subdirectory is entered |
/h |
bool (true) |
Suppress the file announcements of §3.4. When false, every examined file appears in the output exactly once |
/v |
bool (false) |
List the resolved option set at the top of output, in the form §5.3 fixes |
/H |
bool (false) |
Print the help text of §5.1 to stdout, exit 0, and do not traverse |
/n |
bool (false) |
Give a block one detail line per matching line, carrying the 1-based line number |
/L |
bool (false) |
Give a block one detail line per matching line, carrying that line's text |
/p row
defines an extension as the file's last dot-suffix, a leading dot on the name
notwithstanding, so .gitignore has extension gitignore and a
dot-file is searched like any other. It also fixes normalization: each item is trimmed,
loses one leading dot if present, and empty items are discarded, so "cpp,,rs"
and "cpp, rs" name the same two extensions. And it fixes comparison as
case-sensitive on POSIX and case-insensitive on Windows.
/r row rejects an empty argument. That is a rule with a history: an earlier
draft claimed an empty expression compiles and matches every line, and the review found the
claim did not hold across engines. The answer was to require the default .
instead and give the empty case a diagnostic of its own.
<executable> replaced by its own executable name, and
its first line alone serves as the usage line that terminates every usage diagnostic.
usage: <executable> [/P path] [/p "ext, ext"] [/r regex] [/s bool] [/h bool] [/v bool] [/H bool] [/n bool] [/L bool]
/P path (.) root path for traversal; repeat to add more root paths
/p "ext, ext" () comma-separated bare extensions to search; empty searches every file
/r regex (.) regular expression evaluated against each line
/s true|false (true) recurse into subdirectories
/h true|false (true) hide files that matched nothing; errors always appear
/v true|false (false) list the resolved option set before traversal
/H true|false (false) print this help and exit
/n true|false (false) add a detail line per match, carrying the line number
/L true|false (false) add a detail line per match, carrying the line text
A matching file prints its path on one line; /n and /L add indented detail
lines beneath it. A path is never printed twice. A search ends with a line
counting the files and directories it reached.
Switch introducers / and - are equivalent. Switch letters are case-sensitive,
so /h and /H differ. Every switch takes exactly one argument; there are no bare
flags. Arguments containing whitespace or commas must be quoted.
Run with no switches at all to list the resolved options and exit without
searching.
/H output against it and checks that every one
of the nine switches is listed, and the C# command-line suite asserts its line count.
<token> is the offending token and
<switch> the switch, each reproduced exactly as typed, preserving the
introducer.
| Condition | Reason line |
|---|---|
Token in switch position has no / or - introducer |
not a switch: <token> |
| Introducer-led token that is not a switch defined in §5 | unrecognized switch: <token> |
| Switch is the last token, with no argument following | missing argument for switch: <switch> |
Boolean switch given a value other than true or false |
invalid boolean for <switch>: <token> |
/P given an empty argument |
empty root path for switch: <switch> |
/r given an empty argument |
empty expression for switch: <switch> |
/r given an expression the engine will not compile |
invalid regex for switch: /r |
/ or - included, is an
unrecognized switch. Before that rule, /ss, -abc, and a
bare / each satisfied both conditions.
invalid regex for switch: /r TextFinder
writes the §5.3 listing to stdout whatever /v says. The listing's
/r line carries the offending expression verbatim, which is the point of
emitting it. Under /v true the listing has already been written and is not
repeated.
/v true,
where it precedes the output it explains and traversal follows; on the bare command line of
§3.1, where nothing follows and the process exits 0; and ahead of the invalid-regex
diagnostic, where nothing follows and the process exits 1.
<switch> <value> with a single separating space and terminated by
the single LF §3.4 fixes. /P emits one line per root path;
/p emits the normalized extension list joined by , ;
/r emits the expression verbatim as typed; every boolean emits
true or false in lower case. A command line of
-v true alone produces these nine lines:
/P .
/p
/r .
/s true
/h true
/v true
/H false
/n false
/L false
/p list emits /p alone, with no separating space and no
trailing space, so that no line of the listing ends in whitespace. The specification gives
the reason: a fixture holding this text survives an editor that strips trailing space. A
rule with no stated reason gets tidied away.
/v line reads true only in the listing /v itself
asked for. The other two cases list an option set in which /v was never set,
so a bare command line emits the nine lines above with /v false in place of
/v true.