Skip to content
Myr

docs: update GUIDE to use `lexopt`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

... we migrated off of `clap` long ago.

authored by Andrew Gallant · committed by Micha Reiser · parent 4857d6f · Browse files · 1 file+10 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−11 removed

  • other:+10 added−11 removed

1 file+10 added−11 removed

modified:GUIDE.md+10 added-11 removed
267 unmodified lines
268patterns while the next section covers file type filtering.269270In our ripgrep source code (see [Basics](#basics) for instructions on how to271get a source archive to search), let's say we wanted to see which things depend272on `clap`, our argument parser.272on `lexopt`, our argument parser.273274We could do this:275276```277$ rg clap277$ rg lexopt278[lots of results]279```280281But this shows us many things, and we're only interested in where we wrote282`clap` as a dependency. Instead, we could limit ourselves to TOML files, which283is how dependencies are communicated to Rust's build tool, Cargo:282`lexopt` as a dependency. Instead, we could limit ourselves to TOML files,283which is how dependencies are communicated to Rust's build tool, Cargo:284285```286$ rg clap -g '*.toml'286$ rg lexopt -g '*.toml'287Cargo.toml28835:clap = "2.26"28951:clap = "2.26"28857:lexopt = "0.3.0"289```290291The `-g '*.toml'` syntax says, "make sure every file searched matches this292glob pattern." Note that we put `'*.toml'` in single quotes to prevent our
1 unmodified line
294295If we wanted, we could tell ripgrep to search anything *but* `*.toml` files:296297```299$ rg clap -g '!*.toml'298$ rg lexopt -g '!*.toml'299[lots of results]300```301302This will give you a lot of results again as above, but they won't include
7 unmodified lines
310is, later globs will override earlier globs. For example, the following command311will search only `*.toml` files:312313```315$ rg clap -g '!*.toml' -g '*.toml'314$ rg lexopt -g '!*.toml' -g '*.toml'315```316317Interestingly, reversing the order of the globs in this case will match318nothing, since the presence of at least one non-blacklist glob will institute a
43 unmodified lines
362363Just as you can write blacklist globs, you can blacklist file types too:364365```367$ rg clap --type-not rust366$ rg lexopt --type-not rust367```368369or, more succinctly,370371```373$ rg clap -Trust372$ rg lexopt -Trust373```374375That is, `-t` means "include files of this type" where as `-T` means "exclude376files of this type."
649 unmodified lines