Commit Graph

147 Commits

Author SHA1 Message Date
Jonah Caplan 08d913f167 cargo fmt fixup 2021-10-15 23:56:36 -04:00
Jonah Caplan 6b92c5db90 add -N/--no-strip option to show "./" prefix on relative paths 2021-10-15 23:56:36 -04:00
Tavian Barnes 7b5b3ec47b walk: Add a cache for DirEntry metadata 2021-10-13 09:13:44 +02:00
Tavian Barnes 476d404938
Merge pull request #817 from will459/add_no_ignore_parent
Add --no-ignore-parent flag
2021-09-01 13:22:01 -04:00
William Correia 43f5c8adc9
Add tests for --no-ignore-parent 2021-08-31 18:04:42 -04:00
Vukašin Stepanović c749c95136 Merge branch 'master' into pr/opposing-options 2021-08-23 15:55:17 +02:00
Asha20 334488cab7
Add -q/--quiet/--has-match flag (#813)
Instead of printing to stdout, the program will return 1 as the exit
code if there are no matches and 0 otherwise.
2021-08-14 17:57:01 +02:00
Vukašin Stepanović 37852aa388 Add 5 opposing CLI options
Those are:
  - `--no-hidden`, which overrides `--hidden`
  - `--ignore`, which overrides `--no-ignore`
  - `--ignore-vcs`, which overrides `--no-ignore-vcs`
  - `--no-follow`, which overrides `--follow`
  - `--relative-path`, which overrides `--absolute-path`
2021-08-09 15:49:48 +02:00
David Peter 224b7f2354 Silence wrong clippy warning 2021-08-08 23:48:20 +02:00
David Peter aeff525c30 Attempt to fix #365 2021-08-08 15:02:01 +02:00
David Peter b507449146 Handle IO errors based on type, closes #737 2021-08-08 13:10:16 +02:00
Allen Wild 8a532e5196 use custom --path-separator in arguments to --exec
When --path-separator is used, pass it on to commands run with
--exec(-batch) and --list-details.

On Windows, paths with drive letters (C:\foo) and UNC paths
(\\server\share\path) are handled as expected, though they're unlikely
to be found in normal usage of fd.

Fixes: https://github.com/sharkdp/fd/issues/697
2021-02-14 10:24:41 +01:00
sharkdp cadaef3f07 Show error if pattern matches leading dot but --hidden is not given, closes #615 2020-12-06 15:57:33 +01:00
sharkdp d2659de782 Improve --extension help text, closes #673 2020-12-06 12:20:50 +01:00
Platon Pronko e97a1e90cb Add exact size support to the --size filter (#669) 2020-12-06 11:47:27 +01:00
David Peter e0adb45d08
Fail with error message if numeric arguments can not be parsed
closes #675
2020-10-25 21:18:53 +01:00
Matthias Reitinger ec4cc981fc
Add --prune flag
closes #535
2020-10-25 08:16:01 +01:00
sharkdp 726fede7cc Code formatting 2020-05-19 15:57:47 +02:00
DJRHails dc120c547d Add error checking on missing test case 2020-05-19 15:57:47 +02:00
DJRHails bbf3d0d430 Update testenv to support errors that don't fail 2020-05-19 15:57:47 +02:00
DJRHails fef1b91feb Remove test assertion covered by existing tests 2020-05-19 15:57:47 +02:00
DJRHails ca2ef7ba82 Add a test for a single missing search path 2020-05-19 15:57:47 +02:00
Alexandru Macovei 4f4330167a Fix some clippy lints, and format 2020-05-01 14:08:53 +02:00
Seamus Connor b22285ffe4 Fix --glob behavior with empty pattern
With an empty pattern, --glob results in no matches. This does not
align with the behavior of --fixed-strings or --regex. Update the
initialization code to handle globs with empty patterns.
2020-04-26 22:01:29 +02:00
sharkdp 4287cddc00 Add test 2020-04-15 23:32:28 +02:00
sharkdp d63c63be8c Add --min-depth and --exact-depth
Add new `--min-depth <depth>` and `--exact-depth <depth>` options in addition to the existing
option to limit the maximum depth.

closes #404
2020-04-15 17:02:41 +02:00
sharkdp 47974b6479 --glob: '*' does not match on path separators 2020-04-15 16:41:56 +02:00
Danny Mösch 2bab4a2249 Add alias -1 for --max-results=1 2020-04-10 21:39:30 +02:00
sharkdp ea21df3f76 Add tests originally written by @alexmaco in #309 2020-04-04 18:46:08 +02:00
sharkdp 53557ef471 Clean up include order 2020-04-03 22:36:32 +02:00
sharkdp 342d12db3f Remove possibility to use '--exec <cmd>' with a single dash 2020-04-03 22:36:32 +02:00
sharkdp 289d6443a7 Use .write_all 2020-04-03 10:37:53 +02:00
sharkdp 4274075f6f Remove outdated license headers (not strictly required by Apache-2.0) 2020-04-03 10:19:13 +02:00
sharkdp 1714d416e2 Fix test on Windows 2020-04-02 20:27:41 +02:00
sharkdp d43827fe57 Add --max-results=<count> option
This new option can be used instead of piping to `head -n <count>` for
improved performance:

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `fd --max-buffer-time=0 flow.yaml` | 153.9 ± 2.5 | 151.3 | 170.3 | 4.21 ± 5.86 |
| `fd --max-buffer-time=0 flow.yaml \| head -n 1` | 145.3 ± 17.4 | 111.0 | 180.2 | 3.98 ± 5.55 |
| `fd --max-results=1 flow.yaml` | 36.5 ± 50.8 | 7.2 | 145.7 | 1.00 |

Note: there is a large standard deviation on the last result due to the
non-deterministic file system traversal. With `--max-results`, we don't
have to traverse the whole filesystem tree, so it's all about luck.

closes #472
closes #476
2020-04-02 20:27:41 +02:00
sharkdp 918dfc6ef0 Add expected behavior as unit tests 2020-02-28 20:42:14 +01:00
Tom Milligan 06434f229b test: we should find broken symlink with and without --follow 2020-02-28 20:42:14 +01:00
sharkdp 328c6640be Formatting 2020-01-01 12:05:33 +01:00
Simon Engmann 9a34ba6a0c Credit the source of the `device_num()` function 2020-01-01 11:54:01 +01:00
Simon Engmann 2828d90f99 Don't assume that /dev/null exists in test
If `/dev/null` doesn't exist or is not on a different partition during
the test for `--one-file-system`, the test is skipped instead of
mistakenly failing.
2020-01-01 11:54:01 +01:00
Simon Engmann 94993ca6c2 Rename `--same-file-system` to `--one-file-system` 2020-01-01 11:54:01 +01:00
Simon Engmann 3e0325cc60 Adjust tests to not time out on Travis OSX 2020-01-01 11:54:01 +01:00
Simon Engmann e5ba75f3c8 Add tests for `--same-file-system` 2020-01-01 11:54:01 +01:00
Rafał Hajdacki fb205f5057 Allow changing current working directory of fd 2019-12-23 15:42:33 +01:00
sharkdp 50fca2dca2 Disable full-path glob test on Windows 2019-09-15 16:47:38 +02:00
sharkdp 588888112a Adapt full-path glob test for Windows 2019-09-15 16:47:38 +02:00
sharkdp eac20a8132 Add --regex option to override --glob 2019-09-15 16:47:38 +02:00
sharkdp d5da615c17 Implement glob-based searches
closes #284
2019-09-15 16:47:38 +02:00
David Peter 3599a30ee2
Support FILE_ATTRIBUTE_HIDDEN on Windows (#478) 2019-09-15 12:41:04 +02:00
Nathan Moreau 761c445263 Add a non regression test. 2019-09-15 10:57:27 +02:00
Tim Holland 074cfad3d4 Remove deprecated trim_left(_matches)?
warning: use of deprecated item 'core::str::<impl str>::trim_left_matches': superseded by `trim_start_matches`
   --> src/main.rs:222:28
    |
222 |                 .map(|e| e.trim_left_matches('.'))
    |                            ^^^^^^^^^^^^^^^^^
    |
    = note: #[warn(deprecated)] on by default
2019-03-02 08:15:12 +01:00
Alexandru Macovei 051ff5987a [2018 edition] remove all extern crate lines from sources 2019-01-07 12:52:30 +01:00
Alexandru Macovei 64e6ea9fe9 [2018 edition] run cargo fix edition and edition-idioms 2019-01-07 12:52:30 +01:00
kimsnj 6b40a075cd exec-batch: fix a panic with -X "echo {}" and pass stdio to child cmd 2018-11-12 21:11:40 +01:00
kimsnj 45d1b15cff Add support for batch execution of command 2018-11-12 21:11:40 +01:00
sharkdp deea31cbbc Add aliases, change help text 2018-10-27 15:34:10 +02:00
Karim SENHAJI abe8aa55c0 clean-up first implementation of modification date filter 2018-10-10 19:52:37 +02:00
Karim SENHAJI 54c117d72f Add support for --changed-before and --changed-with for modification time based search 2018-10-10 19:52:37 +02:00
sharkdp 27caa33729 cargo fmt 2018-09-27 23:01:38 +02:00
sharkdp aa70c5a446 Add `--type empty`
Add a new `empty`/`e` type to search for empty files and/or directories.

To search for both empty files and directories, use one of the
following:

    fd --type empty
    fd -te

    fd --type empty --type file --type directory

To search for empty files, use

    fd --type empty --type file
    fd -te -tf

To search for empty directories, use

    fd --type empty --type directory
    fd -te -td

closes #273
2018-08-19 17:05:04 +02:00
sharkdp c1ef68662c Update for new rustfmt 2018-05-14 21:00:00 +02:00
sharkdp a3200204dc Simplifications to --size tests 2018-04-29 22:26:10 +02:00
Jonathan e2b2701965 Add helper method to create sized files, use meaningful names and add kibi and kilo tests. 2018-04-29 21:56:31 +02:00
Jonathan 409cf0c7a1 Remove use (which broke the build) 2018-04-29 21:56:31 +02:00
Jonathan f01685c63f Add tests for SizeFilter (--size) fixes sharkdp/fd#289 2018-04-29 21:56:31 +02:00
sharkdp 6a9f16e159 Run latest version of rustfmt 2018-04-13 23:13:22 +02:00
sharkdp 37483036e0 Implement --ignore-file 2018-03-26 08:28:22 +02:00
David Peter 8c1b037279
Normalize absolute paths, fixes #268 (#270)
* Normalize absolute paths, fixes #268
* Split unit tests into several tests
2018-03-25 23:47:58 +02:00
sharkdp 9d840dd485 Separate unit tests 2018-03-25 19:00:46 +02:00
sharkdp 4f6c43a6dc Unit test for --type x 2018-03-25 18:37:50 +02:00
sharkdp 3386b854b0 Run invalid-utf8 on Linux only 2018-02-26 08:20:31 +01:00
sharkdp 47d95284aa Skip invalid utf8 filenames, closes #250 2018-02-26 08:20:31 +01:00
sharkdp b4be1f161c Add support for .fdignore files 2018-02-21 22:55:26 +01:00
sharkdp 814d37030e Implement -F/--fixed-strings/--literal 2018-02-10 15:55:06 +01:00
Martin Larralde 86fe9977e8 Implement multiple suffixes extension support with tests (#214) 2018-02-10 14:18:37 +01:00
Steve Pentland b4d39270d6 Allow -exec to work as --exec (#226)
* Replace usage of `-exec` by `--exec`, except when it is used as a value that is given to `--exec/-exec/-x`.
* Limit usage of --exec option to single instance.
2018-01-29 20:32:46 +01:00
sharkdp a5f5ad6254 Re-enable code style check 2018-01-01 16:00:32 +01:00
Thejaswi Kadur faf934da4b Added support for filtering by multiple filetypes and extensions (#205)
Closes #177 
Closes #199
2018-01-01 12:09:33 +01:00
Dock 51aea57a6a Add multiple path support (#182)
* Adding support for multiple paths. (panic)

- Started adding multiple file support
- fd panics with multiple files right now

* Moved the ctrlc handler to main.

- Moved the ctrlc handler to main so we can search multiple files

* Tests now allow custom directory setup

- TestEnv::new() now takes two arguments, the directories to create and
the files to create inside those directories.

* rust-fmt changes

* rust-fmt changes

* Moving code around, no need to do everything in one big loop

- PathDisplay was never actually used for anything, removed it during refactor of main
- Removed redundant logic for absolute paths
- Moved code placed needlessly inside a loop in the last commit outside of that loop.

* Moving code around, no need to do everything in one big loop

- PathDisplay was never actually used for anything, removed it during refactor of main
- Removed redundant logic for absolute paths
- Moved code placed needlessly inside a loop in the last commit outside of that loop.

* Removed commented code in testenv

* Refactored walk::scan to accept the path buffer vector. Using the ParallelWalker allows for multithreaded searching of multiple directories

* Moved ctrlc handler back into walker, it is only called once from main now.

* Moved the colored output check back to it's original place

* Removing shell-escape, not sure how it got added...

* Added test for `fd 'a.foo' test1` to show that a.foo is only found in the test1 and not the test2 direcotry

* Removing side effect from walk::scan, `dir_vec` is no longer a mutable reference and an iterator is being used instead.

* Running rustfmt to format code correctly
2017-12-06 14:52:23 -08:00
ptzz 9bd1d12c00 Add --no-ignore-vcs option
When passed, .gitignore files will not be respected.
2017-11-22 23:18:22 +01:00
Matthias Reitinger bc88b8f80e Fix exec tests 2017-11-15 23:18:36 +01:00
sharkdp bba5c4f607 Fix some clippy warnings 2017-10-26 21:13:56 +02:00
J.W 614f576c47 Add TODOs and FIXMEs about Windows 2017-10-26 20:56:32 +02:00
J.W dc29ef70c4 Fix Input::remove_extension and Input::dirname 2017-10-26 20:56:32 +02:00
J.W d702d849ea Test --exec on Unix 2017-10-26 20:56:32 +02:00
sharkdp 5ad69fb2fb Add support for exclude-patterns
* Add `--exclude`/`-E` option.
* Support for multiple exclude patterns

Example:
``` bash
> fd --exclude 'tests/**/*.rs' mod
src/exec/mod.rs
src/fshelper/mod.rs
src/lscolors/mod.rs
```

Closes #89
2017-10-25 22:22:12 +02:00
Antti Keränen 701b8f209b Relicense under MIT/Apache-2.0 2017-10-22 10:36:42 +02:00
J.W 8d85debc12 Refactor path handling (fixes #113)
* Fix path check
* Fix full path matching
* Allow more simple driver names in Windows tests
* Factor out special is_dir() check for "." and ".."
2017-10-18 20:04:34 +02:00
J.W e649c8fa79 Use a uniform output format for searching ../
closes #107, fixes #82 by the way
2017-10-15 15:01:24 +02:00
Matthias Reitinger b441528067 Improve smart case to only consider literal uppercase chars (#103) 2017-10-14 11:03:21 +02:00
sharkdp 8fc3a83d92 Use absolute path to perform search, fixes #81
Previously, we were using the relative path to extract the search
string. For the current directory, the returned relative path was equal
to `""`. This is why the current directory did not show in the search
results (see #81).

This commit also changes the way that `--full-path` works, which was
previously working on relative paths. It seems more useful to search the
absolute path, though. Otherwise, search results could change just by
calling fd (with a given search path) from a different directory.
2017-10-13 18:16:26 +02:00
Antti Keränen 049b9ec06b Format the source code using `rustfmt` 2017-10-12 19:33:14 +02:00
J.W e075e1cf7c Add -i, --ignore-case 2017-10-12 07:28:05 +02:00
Rav Chandra 4f2d9e77b3 Add ripgrep aliases for no-ignore and hidden 2017-10-11 23:15:21 +02:00
Jean-Christophe Petkovich affe41949d Switch symlink arg from 's' to 'l' (#83)
closes #80
2017-10-09 21:25:30 +02:00
David Peter 4731dc670c Enhanced Windows support, see #70
* Use easier way to convert path components
* Fix failing tests on Windows
2017-10-07 09:40:44 +02:00
Matthias Reitinger 6f22957cdc Re-write integration tests in Rust (#67)
* Rewrite integration tests in Rust.
* Improve failure output for integration tests.
* Move TestEnv to separate module.
* Remove old integration tests script.
* Re-add integration test for subdirectory.
2017-10-04 23:19:30 +02:00