Skip to content
Myr

Merge pull request #822 from Asha20/pr/opposing-options

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

Add opposing CLI options

authored by David Peter · committed by GitHub · parents 2570fbd, cdc6a37 · Browse files · 6 files+139 added−8 removed
This commit

State

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

Diff stats

6 files+139 added−8 removed

  • tests:+25 added−0 removed
  • other:+114 added−8 removed

6 files+139 added−8 removed

modified:doc/fd.1+6 added-2 removed
26 unmodified lines
27.SH OPTIONS28.TP29.B \-H, \-\-hidden30Include hidden files and directories in the search results31(default: hidden files and directories are skipped).31(default: hidden files and directories are skipped). The flag can be overridden with '--no-hidden'.32.TP33.B \-I, \-\-no\-ignore34Show search results from files and directories that would otherwise be ignored by35.RS
12 unmodified lines
48The global fd ignore file (usually49.I $HOME/.config/fd/ignore50)51.RE52.IP53The flag can be overridden with '--ignore'.54.TP55.B \-u, \-\-unrestricted56Alias for '--no-ignore'. Can be repeated; '-uu' is an alias for '--no-ignore --hidden'.57.TP
5 unmodified lines
63and the global gitignore configuration64.RI ( core.excludesFile65git setting, which defaults to66.IR $HOME/.config/git/ignore ).67The flag can be overridden with '--ignore-vcs'.68.TP69.B \-s, \-\-case\-sensitive70Perform a case-sensitive search. By default, fd uses case-insensitive searches, unless the71pattern contains an uppercase character (smart case).
14 unmodified lines
86performs substring comparison. If you want to match on an exact filename, consider using '\-\-glob'.87.TP88.B \-a, \-\-absolute\-path89Shows the full path starting from the root as opposed to relative paths.90The flag can be overridden with '--relative-path'.91.TP92.B \-l, \-\-list\-details93Use a detailed listing format like 'ls -l'. This is basically an alias94for '--exec-batch ls -l' with some additional 'ls' options. This can be used
1 unmodified line
96sort order.97.TP98.B \-L, \-\-follow99By default, fd does not descend into symlinked directories. Using this flag, symbolic links are96also traversed.100also traversed. The flag can be overridden with '--no-follow'.101.TP102.B \-p, \-\-full\-path103By default, the search pattern is only matched against the filename (or directory name). Using104this flag, the
315 unmodified lines
modified:src/app.rs+55 added-5 removed
23 unmodified lines
24 .help("Search hidden files and directories")25 .long_help(26 "Include hidden directories and files in the search results (default: \27 hidden files and directories are skipped). Files and directories are \28 considered to be hidden if their name starts with a `.` sign (dot).",28 considered to be hidden if their name starts with a `.` sign (dot). \29 The flag can be overridden with --no-hidden.",30 ),31 )32 .arg(33 Arg::with_name("no-hidden")34 .long("no-hidden")35 .overrides_with("hidden")36 .hidden(true)37 .long_help(38 "Overrides --hidden.",39 ),40 )41 .arg(42 Arg::with_name("no-ignore")43 .long("no-ignore")44 .short("I")45 .overrides_with("no-ignore")46 .help("Do not respect .(git|fd)ignore files")47 .long_help(48 "Show search results from files and directories that would otherwise be \39 ignored by '.gitignore', '.ignore', '.fdignore', or the global ignore file.",49 ignored by '.gitignore', '.ignore', '.fdignore', or the global ignore file. \50 The flag can be overridden with --ignore.",51 ),52 )53 .arg(54 Arg::with_name("ignore")55 .long("ignore")56 .overrides_with("no-ignore")57 .hidden(true)58 .long_help(59 "Overrides --no-ignore.",60 ),61 )62 .arg(63 Arg::with_name("no-ignore-vcs")64 .long("no-ignore-vcs")65 .overrides_with("no-ignore-vcs")66 .hidden_short_help(true)67 .help("Do not respect .gitignore files")68 .long_help(69 "Show search results from files and directories that would otherwise be \50 ignored by '.gitignore' files.",70 ignored by '.gitignore' files. The flag can be overridden with --ignore-vcs.",71 ),72 )73 .arg(74 Arg::with_name("ignore-vcs")75 .long("ignore-vcs")76 .overrides_with("no-ignore-vcs")77 .hidden(true)78 .long_help(79 "Overrides --no-ignore-vcs.",80 ),81 )82 .arg(83 Arg::with_name("no-ignore-parent")84 .long("no-ignore-parent")85 .overrides_with("no-ignore-parent")86 .hidden_short_help(true)
13 unmodified lines
100 .arg(101 Arg::with_name("rg-alias-hidden-ignore")102 .short("u")103 .long("unrestricted")104 .overrides_with_all(&["ignore", "no-hidden"])105 .multiple(true)106 .hidden_short_help(true)107 .help("Alias for '--no-ignore', and '--hidden' when given twice")108 .long_help(
65 unmodified lines
174 .short("a")175 .overrides_with("absolute-path")176 .help("Show absolute instead of relative paths")177 .long_help(148 "Shows the full path starting from the root as opposed to relative paths.",178 "Shows the full path starting from the root as opposed to relative paths. \179 The flag can be overridden with --relative-path.",180 ),181 )182 .arg(183 Arg::with_name("relative-path")184 .long("relative-path")185 .overrides_with("absolute-path")186 .hidden(true)187 .long_help(188 "Overrides --absolute-path.",189 ),190 )191 .arg(192 Arg::with_name("list-details")193 .long("list-details")194 .short("l")195 .conflicts_with("absolute-path")
13 unmodified lines
209 .overrides_with("follow")210 .help("Follow symbolic links")211 .long_help(212 "By default, fd does not descend into symlinked directories. Using this \173 flag, symbolic links are also traversed.",213 flag, symbolic links are also traversed. \214 Flag can be overriden with --no-follow.",215 ),216 )217 .arg(218 Arg::with_name("no-follow")219 .long("no-follow")220 .overrides_with("follow")221 .hidden(true)222 .long_help(223 "Overrides --follow.",224 ),225 )226 .arg(227 Arg::with_name("full-path")228 .long("full-path")229 .short("p")230 .overrides_with("full-path")
496 unmodified lines
modified:tests/tests.rs+25 added
2 unmodified lines
3use std::fs;4use std::io::Write;5use std::path::Path;6use std::time::{Duration, SystemTime};7use test_case::test_case;89use normpath::PathExt;10use regex::escape;11
1917 unmodified lines
19291930 te.assert_failure(&["--max-results=a"]);1931}19321933#[test_case("--hidden", &["--no-hidden"] ; "hidden")]1934#[test_case("--no-ignore", &["--ignore"] ; "no-ignore")]1935#[test_case("--no-ignore-vcs", &["--ignore-vcs"] ; "no-ignore-vcs")]1936#[test_case("--follow", &["--no-follow"] ; "follow")]1937#[test_case("--absolute-path", &["--relative-path"] ; "absolute-path")]1938#[test_case("-u", &["--ignore"] ; "u")]1939#[test_case("-uu", &["--ignore", "--no-hidden"] ; "uu")]1940fn test_opposing(flag: &str, opposing_flags: &[&str]) {1941 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);19421943 let mut flags = vec![flag];1944 flags.extend_from_slice(opposing_flags);1945 let out_no_flags = te.assert_success_and_get_output(".", &[]);1946 let out_opposing_flags = te.assert_success_and_get_output(".", &flags);19471948 assert_eq!(1949 out_no_flags,1950 out_opposing_flags,1951 "{} should override {}",1952 opposing_flags.join(" "),1953 flag1954 );1955}19561957/// Print error if search pattern starts with a dot and --hidden is not set1958/// (Unix only, hidden files on Windows work differently)1959#[test]1960#[cfg(unix)]
10 unmodified lines
modified:Cargo.lock+49 added
179 unmodified lines
180 "once_cell",181 "regex",182 "regex-syntax",183 "tempdir",184 "test-case",185 "users",186 "version_check",187]188
207 unmodified lines
396source = "registry+https://github.com/rust-lang/crates.io-index"397checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"398399[[package]]400name = "proc-macro2"401version = "1.0.32"402source = "registry+https://github.com/rust-lang/crates.io-index"403checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"404dependencies = [405 "unicode-xid",406]407408[[package]]409name = "quote"410version = "1.0.10"411source = "registry+https://github.com/rust-lang/crates.io-index"412checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"413dependencies = [414 "proc-macro2",415]416417[[package]]418name = "rand"419version = "0.4.6"420source = "registry+https://github.com/rust-lang/crates.io-index"421checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
89 unmodified lines
511source = "registry+https://github.com/rust-lang/crates.io-index"512checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"513514[[package]]515name = "syn"516version = "1.0.81"517source = "registry+https://github.com/rust-lang/crates.io-index"518checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966"519dependencies = [520 "proc-macro2",521 "quote",522 "unicode-xid",523]524525[[package]]526name = "tempdir"527version = "0.3.7"528source = "registry+https://github.com/rust-lang/crates.io-index"529checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
12 unmodified lines
542 "winapi",543]544545[[package]]546name = "test-case"547version = "1.2.1"548source = "registry+https://github.com/rust-lang/crates.io-index"549checksum = "c7cad0a06f9a61e94355aa3b3dc92d85ab9c83406722b1ca5e918d4297c12c23"550dependencies = [551 "cfg-if",552 "proc-macro2",553 "quote",554 "syn",555 "version_check",556]557558[[package]]559name = "textwrap"560version = "0.11.0"561source = "registry+https://github.com/rust-lang/crates.io-index"562checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
27 unmodified lines
590source = "registry+https://github.com/rust-lang/crates.io-index"591checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"592593[[package]]594name = "unicode-xid"595version = "0.2.2"596source = "registry+https://github.com/rust-lang/crates.io-index"597checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"598599[[package]]600name = "users"601version = "0.11.0"602source = "registry+https://github.com/rust-lang/crates.io-index"603checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032"
64 unmodified lines
modified:Cargo.toml+2 added-1 removed
modified:CHANGELOG.md+2 added
12 unmodified lines
13- Add new `--no-ignore-parent` flag, see #787 (@will459)1415- Add new `--batch-size` flag, see #410 (@devonhollowood)1617- Add opposing command-line options, see #595 (@Asha20)1819## Bugfixes2021- Set default path separator to `/` in MSYS, see #537 and #730 (@aswild)22- fd cannot search files under a RAM disk, see #752
519 unmodified lines