Commit Graph

146 Commits

Author SHA1 Message Date
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
ed024ceb54 Remove code duplication, add feature gate 2020-04-04 18:46:08 +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
c428f52209 Run cargo fmt 2018-08-03 21:20:48 +02:00
sharkdp
59c9901cde Update dependencies, fix #313 2018-08-03 21:20:48 +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
Matthias Reitinger
b0fb774c0e Fix test suite name 2017-10-03 18:28:54 +02:00
Matthias Reitinger
83db8673cf Add extension filtering 2017-10-03 18:28:54 +02:00
exitium
2a3dd5b631 Add file type filtering 2017-09-17 09:25:01 +02:00
sharkdp
fde8f2e8e3 Try to fix test on macOS 2017-09-09 16:42:10 +02:00
sharkdp
a790f9bd62 Remove unicode test 2017-09-09 16:26:33 +02:00
sharkdp
2d1d24c38c Rename config parameter for print0 and fix sorting in tests 2017-08-01 22:36:38 +02:00
Michael Mior
1b0c8f349a Add --print0 option 2017-07-19 17:10:06 -04:00
sharkdp
918e4a014a Fix warning in tests on Linux 2017-07-02 16:01:08 +02:00
sharkdp
f5261595a7 Stabilize sort results 2017-06-15 16:12:11 +02:00
sharkdp
d8d0cf5d6e Modify test.sh for macOS, fixes #44 2017-06-15 16:12:11 +02:00
sharkdp
3f69c0fa1a Update test.sh script, see #44 2017-06-13 21:08:02 +02:00
sharkdp
54f33e5227 Use absolute paths if root dir is an absolute path, fixes #40 2017-06-11 20:55:01 +02:00
sharkdp
24070b0be0 Handle invalid UTF-8, fixes #34 2017-06-11 15:38:56 +02:00
sharkdp
087e709acd Use clap, change --sensitive to --case-sensitive
see #33
2017-06-11 14:25:58 +02:00
sharkdp
8adb5b9f84 Add option to print absolute paths, closes #10 2017-06-05 21:18:27 +02:00
sharkdp
634016b9a0 Add optional second argument, closes #5 2017-06-05 16:25:13 +02:00
sharkdp
d29115b4da Change .gitignore to .ignore 2017-05-28 19:35:27 +02:00
sharkdp
0757a50c31 Add more unit tests, search directories and symlinks too 2017-05-24 22:16:55 +02:00
sharkdp
10cd964c1d Add simple integration tests 2017-05-23 00:34:27 +02:00