mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e5da9cd844 | |||
| b4a517a096 | |||
| e654d30f9d | |||
| 4fc1897678 | |||
| 08b9c756ee | |||
| 394231683d | |||
| a06a001886 | |||
| fd9e97bcfa | |||
| 3ed95ee399 | |||
| 58c9f6d509 | |||
| 3f2f7a8bb2 | |||
| b7176cf887 | |||
| d65f41097e | |||
| 08e4240b41 | |||
| 028ca1fdc7 | |||
| 4f6255971b | |||
| cab250aa0e | |||
| 5f76db27c9 | |||
| a34e78f912 | |||
| 1ffda38264 | |||
| e78690e4f5 | |||
| 5b87260467 | |||
| 2c34c38b29 | |||
| a1574d6a06 | |||
| 184ea1f956 | |||
| a3dcab9454 | |||
| 658b11d0f8 | |||
| e2fe656296 | |||
| 87581f328e | |||
| ecd6b85c17 | |||
| b86e5c8c88 |
Generated
+189
-7
@@ -11,6 +11,21 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android-tzdata"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_system_properties"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ansi_term"
|
name = "ansi_term"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
@@ -83,6 +98,12 @@ dependencies = [
|
|||||||
"wait-timeout",
|
"wait-timeout",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
@@ -106,6 +127,18 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.0.97"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
@@ -118,6 +151,20 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
|
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono"
|
||||||
|
version = "0.4.38"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
|
||||||
|
dependencies = [
|
||||||
|
"android-tzdata",
|
||||||
|
"iana-time-zone",
|
||||||
|
"js-sys",
|
||||||
|
"num-traits",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-targets 0.52.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.4"
|
version = "4.5.4"
|
||||||
@@ -256,10 +303,11 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "du-dust"
|
name = "du-dust"
|
||||||
version = "0.9.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
"clap_mangen",
|
"clap_mangen",
|
||||||
@@ -271,6 +319,7 @@ dependencies = [
|
|||||||
"rayon",
|
"rayon",
|
||||||
"regex",
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"stfu8",
|
"stfu8",
|
||||||
"sysinfo",
|
"sysinfo",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
@@ -328,6 +377,29 @@ version = "0.3.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone"
|
||||||
|
version = "0.1.60"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
|
||||||
|
dependencies = [
|
||||||
|
"android_system_properties",
|
||||||
|
"core-foundation-sys",
|
||||||
|
"iana-time-zone-haiku",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone-haiku"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "io-lifetimes"
|
name = "io-lifetimes"
|
||||||
version = "1.0.11"
|
version = "1.0.11"
|
||||||
@@ -340,10 +412,25 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "itoa"
|
||||||
version = "0.2.153"
|
version = "1.0.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.69"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.155"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libredox"
|
name = "libredox"
|
||||||
@@ -368,6 +455,12 @@ version = "0.4.13"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
|
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lscolors"
|
name = "lscolors"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
@@ -415,6 +508,15 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.19.0"
|
version = "1.19.0"
|
||||||
@@ -574,6 +676,12 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.197"
|
version = "1.0.197"
|
||||||
@@ -594,6 +702,17 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.116"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stfu8"
|
name = "stfu8"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
@@ -728,6 +847,60 @@ version = "0.11.0+wasi-snapshot-preview1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-backend"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@@ -746,11 +919,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-util"
|
name = "winapi-util"
|
||||||
version = "0.1.6"
|
version = "0.1.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
|
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -759,6 +932,15 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
|
|||||||
+3
-1
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "du-dust"
|
name = "du-dust"
|
||||||
description = "A more intuitive version of du"
|
description = "A more intuitive version of du"
|
||||||
version = "0.9.0"
|
version = "1.1.0"
|
||||||
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
|
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@@ -38,9 +38,11 @@ stfu8 = "0.2"
|
|||||||
regex = "1"
|
regex = "1"
|
||||||
config-file = "0.2"
|
config-file = "0.2"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1.0"
|
||||||
directories = "4"
|
directories = "4"
|
||||||
sysinfo = "0.27"
|
sysinfo = "0.27"
|
||||||
ctrlc = "3.4"
|
ctrlc = "3.4"
|
||||||
|
chrono = "0.4"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winapi-util = "0.1"
|
winapi-util = "0.1"
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ Usage: dust -R (For screen readers. Removes bars/symbols. Adds new column: depth
|
|||||||
Usage: dust -S (Custom Stack size - Use if you see: 'fatal runtime error: stack overflow' (default allocation: low memory=1048576, high memory=1073741824)"),
|
Usage: dust -S (Custom Stack size - Use if you see: 'fatal runtime error: stack overflow' (default allocation: low memory=1048576, high memory=1073741824)"),
|
||||||
Usage: dust --skip-total (No total row will be displayed)
|
Usage: dust --skip-total (No total row will be displayed)
|
||||||
Usage: dust -z 40000/30MB/20kib (Exclude output files/directories below size 40000 bytes / 30MB / 20KiB)
|
Usage: dust -z 40000/30MB/20kib (Exclude output files/directories below size 40000 bytes / 30MB / 20KiB)
|
||||||
|
Usage: dust -j (Prints JSON representation of directories, try: dust -j | jq)
|
||||||
|
Usage: dust --files0-from=FILE (Reads null-terminated file paths from FILE); If FILE is - then read from stdin
|
||||||
```
|
```
|
||||||
|
|
||||||
## Config file
|
## Config file
|
||||||
|
|||||||
+5
-3
@@ -1,14 +1,16 @@
|
|||||||
# ----------- To do a release ---------
|
# ----------- To do a release ---------
|
||||||
# Compare times of runs to check no drastic slow down:
|
# Compare times of runs to check no drastic slow down:
|
||||||
# time target/release/dust ~/dev
|
# hyperfine 'target/release/dust /home/andy'
|
||||||
# time dust ~dev
|
# hyperfine 'dust /home/andy'
|
||||||
|
|
||||||
# edit version in cargo.toml
|
# edit version in cargo.toml
|
||||||
|
# cargo build --release
|
||||||
|
# commit changed files
|
||||||
# tag a commit and push (increment version in Cargo.toml first):
|
# tag a commit and push (increment version in Cargo.toml first):
|
||||||
# git tag v0.4.5
|
# git tag v0.4.5
|
||||||
# git push origin v0.4.5
|
# git push origin v0.4.5
|
||||||
|
|
||||||
# cargo publish to put it in crates.io
|
# cargo publish to put it in crates.io
|
||||||
|
|
||||||
# To install locally [Do before pushing it]
|
# To install locally [Do before pushing it]
|
||||||
#cargo install --path .
|
#cargo install --path .
|
||||||
|
|||||||
+33
-21
@@ -15,26 +15,35 @@ _dust() {
|
|||||||
|
|
||||||
local context curcontext="$curcontext" state line
|
local context curcontext="$curcontext" state line
|
||||||
_arguments "${_arguments_options[@]}" \
|
_arguments "${_arguments_options[@]}" \
|
||||||
'-d+[Depth to show]: : ' \
|
'-d+[Depth to show]:DEPTH: ' \
|
||||||
'--depth=[Depth to show]: : ' \
|
'--depth=[Depth to show]:DEPTH: ' \
|
||||||
'-n+[Number of lines of output to show. (Default is terminal_height - 10)]: : ' \
|
'-T+[Number of threads to use]: : ' \
|
||||||
'--number-of-lines=[Number of lines of output to show. (Default is terminal_height - 10)]: : ' \
|
'--threads=[Number of threads to use]: : ' \
|
||||||
'*-X+[Exclude any file or directory with this name]: : ' \
|
'-n+[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER: ' \
|
||||||
'*--ignore-directory=[Exclude any file or directory with this name]: : ' \
|
'--number-of-lines=[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER: ' \
|
||||||
'-I+[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]: : ' \
|
'*-X+[Exclude any file or directory with this name]:PATH:_files' \
|
||||||
'--ignore-all-in-file=[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]: : ' \
|
'*--ignore-directory=[Exclude any file or directory with this name]:PATH:_files' \
|
||||||
'-z+[Minimum size file to include in output]: : ' \
|
'-I+[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:FILE:_files' \
|
||||||
'--min-size=[Minimum size file to include in output]: : ' \
|
'--ignore-all-in-file=[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:FILE:_files' \
|
||||||
'(-e --filter -t --file_types)*-v+[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]: : ' \
|
'-z+[Minimum size file to include in output]:MIN_SIZE: ' \
|
||||||
'(-e --filter -t --file_types)*--invert-filter=[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]: : ' \
|
'--min-size=[Minimum size file to include in output]:MIN_SIZE: ' \
|
||||||
'(-t --file_types)*-e+[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]: : ' \
|
'(-e --filter -t --file_types)*-v+[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]:REGEX: ' \
|
||||||
'(-t --file_types)*--filter=[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]: : ' \
|
'(-e --filter -t --file_types)*--invert-filter=[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]:REGEX: ' \
|
||||||
'-w+[Specify width of output overriding the auto detection of terminal width]: : ' \
|
'(-t --file_types)*-e+[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]:REGEX: ' \
|
||||||
'--terminal_width=[Specify width of output overriding the auto detection of terminal width]: : ' \
|
'(-t --file_types)*--filter=[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]:REGEX: ' \
|
||||||
'-o+[Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size]: : ' \
|
'-w+[Specify width of output overriding the auto detection of terminal width]:WIDTH: ' \
|
||||||
'--output-format=[Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size]: : ' \
|
'--terminal_width=[Specify width of output overriding the auto detection of terminal width]:WIDTH: ' \
|
||||||
'-S+[Specify memory to use as stack size - use if you see\: '\''fatal runtime error\: stack overflow'\'' (default low memory=1048576, high memory=1073741824)]: : ' \
|
'-o+[Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.]:FORMAT:(si b k m g t kb mb gb tb)' \
|
||||||
'--stack-size=[Specify memory to use as stack size - use if you see\: '\''fatal runtime error\: stack overflow'\'' (default low memory=1048576, high memory=1073741824)]: : ' \
|
'--output-format=[Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.]:FORMAT:(si b k m g t kb mb gb tb)' \
|
||||||
|
'-S+[Specify memory to use as stack size - use if you see\: '\''fatal runtime error\: stack overflow'\'' (default low memory=1048576, high memory=1073741824)]:STACK_SIZE: ' \
|
||||||
|
'--stack-size=[Specify memory to use as stack size - use if you see\: '\''fatal runtime error\: stack overflow'\'' (default low memory=1048576, high memory=1073741824)]:STACK_SIZE: ' \
|
||||||
|
'-M+[+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => \[curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)]: : ' \
|
||||||
|
'--mtime=[+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => \[curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)]: : ' \
|
||||||
|
'-A+[just like -mtime, but based on file access time]: : ' \
|
||||||
|
'--atime=[just like -mtime, but based on file access time]: : ' \
|
||||||
|
'-y+[just like -mtime, but based on file change time]: : ' \
|
||||||
|
'--ctime=[just like -mtime, but based on file change time]: : ' \
|
||||||
|
'--files0-from=[run dust on NUL-terminated file names specified in file; if argument is -, then read names from standard input]: :_files' \
|
||||||
'-p[Subdirectories will not have their path shortened]' \
|
'-p[Subdirectories will not have their path shortened]' \
|
||||||
'--full-paths[Subdirectories will not have their path shortened]' \
|
'--full-paths[Subdirectories will not have their path shortened]' \
|
||||||
'-L[dereference sym links - Treat sym links as directories and go into them]' \
|
'-L[dereference sym links - Treat sym links as directories and go into them]' \
|
||||||
@@ -64,15 +73,18 @@ _dust() {
|
|||||||
'(-d --depth -D --only-dir)--file_types[show only these file types]' \
|
'(-d --depth -D --only-dir)--file_types[show only these file types]' \
|
||||||
'-P[Disable the progress indication.]' \
|
'-P[Disable the progress indication.]' \
|
||||||
'--no-progress[Disable the progress indication.]' \
|
'--no-progress[Disable the progress indication.]' \
|
||||||
|
'--print-errors[Print path with errors.]' \
|
||||||
'(-F --only-file -t --file_types)-D[Only directories will be displayed.]' \
|
'(-F --only-file -t --file_types)-D[Only directories will be displayed.]' \
|
||||||
'(-F --only-file -t --file_types)--only-dir[Only directories will be displayed.]' \
|
'(-F --only-file -t --file_types)--only-dir[Only directories will be displayed.]' \
|
||||||
'(-D --only-dir)-F[Only files will be displayed. (Finds your largest files)]' \
|
'(-D --only-dir)-F[Only files will be displayed. (Finds your largest files)]' \
|
||||||
'(-D --only-dir)--only-file[Only files will be displayed. (Finds your largest files)]' \
|
'(-D --only-dir)--only-file[Only files will be displayed. (Finds your largest files)]' \
|
||||||
|
'-j[Output the directory tree as json to the current directory]' \
|
||||||
|
'--output-json[Output the directory tree as json to the current directory]' \
|
||||||
'-h[Print help]' \
|
'-h[Print help]' \
|
||||||
'--help[Print help]' \
|
'--help[Print help]' \
|
||||||
'-V[Print version]' \
|
'-V[Print version]' \
|
||||||
'--version[Print version]' \
|
'--version[Print version]' \
|
||||||
'*::params:' \
|
'*::params:_files' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-2
@@ -23,6 +23,8 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
|||||||
'dust' {
|
'dust' {
|
||||||
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Depth to show')
|
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Depth to show')
|
||||||
[CompletionResult]::new('--depth', 'depth', [CompletionResultType]::ParameterName, 'Depth to show')
|
[CompletionResult]::new('--depth', 'depth', [CompletionResultType]::ParameterName, 'Depth to show')
|
||||||
|
[CompletionResult]::new('-T', 'T ', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
||||||
|
[CompletionResult]::new('--threads', 'threads', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
||||||
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
|
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
|
||||||
[CompletionResult]::new('--number-of-lines', 'number-of-lines', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
|
[CompletionResult]::new('--number-of-lines', 'number-of-lines', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
|
||||||
[CompletionResult]::new('-X', 'X ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this name')
|
[CompletionResult]::new('-X', 'X ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this name')
|
||||||
@@ -37,10 +39,17 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
|||||||
[CompletionResult]::new('--filter', 'filter', [CompletionResultType]::ParameterName, 'Only include filepaths matching this regex. For png files type: -e "\.png$" ')
|
[CompletionResult]::new('--filter', 'filter', [CompletionResultType]::ParameterName, 'Only include filepaths matching this regex. For png files type: -e "\.png$" ')
|
||||||
[CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width')
|
[CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width')
|
||||||
[CompletionResult]::new('--terminal_width', 'terminal_width', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width')
|
[CompletionResult]::new('--terminal_width', 'terminal_width', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width')
|
||||||
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size')
|
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.')
|
||||||
[CompletionResult]::new('--output-format', 'output-format', [CompletionResultType]::ParameterName, 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size')
|
[CompletionResult]::new('--output-format', 'output-format', [CompletionResultType]::ParameterName, 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.')
|
||||||
[CompletionResult]::new('-S', 'S ', [CompletionResultType]::ParameterName, 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)')
|
[CompletionResult]::new('-S', 'S ', [CompletionResultType]::ParameterName, 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)')
|
||||||
[CompletionResult]::new('--stack-size', 'stack-size', [CompletionResultType]::ParameterName, 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)')
|
[CompletionResult]::new('--stack-size', 'stack-size', [CompletionResultType]::ParameterName, 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)')
|
||||||
|
[CompletionResult]::new('-M', 'M ', [CompletionResultType]::ParameterName, '+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)')
|
||||||
|
[CompletionResult]::new('--mtime', 'mtime', [CompletionResultType]::ParameterName, '+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)')
|
||||||
|
[CompletionResult]::new('-A', 'A ', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file access time')
|
||||||
|
[CompletionResult]::new('--atime', 'atime', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file access time')
|
||||||
|
[CompletionResult]::new('-y', 'y', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file change time')
|
||||||
|
[CompletionResult]::new('--ctime', 'ctime', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file change time')
|
||||||
|
[CompletionResult]::new('--files0-from', 'files0-from', [CompletionResultType]::ParameterName, 'run dust on NUL-terminated file names specified in file; if argument is -, then read names from standard input')
|
||||||
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
|
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
|
||||||
[CompletionResult]::new('--full-paths', 'full-paths', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
|
[CompletionResult]::new('--full-paths', 'full-paths', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
|
||||||
[CompletionResult]::new('-L', 'L ', [CompletionResultType]::ParameterName, 'dereference sym links - Treat sym links as directories and go into them')
|
[CompletionResult]::new('-L', 'L ', [CompletionResultType]::ParameterName, 'dereference sym links - Treat sym links as directories and go into them')
|
||||||
@@ -70,10 +79,13 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
|||||||
[CompletionResult]::new('--file_types', 'file_types', [CompletionResultType]::ParameterName, 'show only these file types')
|
[CompletionResult]::new('--file_types', 'file_types', [CompletionResultType]::ParameterName, 'show only these file types')
|
||||||
[CompletionResult]::new('-P', 'P ', [CompletionResultType]::ParameterName, 'Disable the progress indication.')
|
[CompletionResult]::new('-P', 'P ', [CompletionResultType]::ParameterName, 'Disable the progress indication.')
|
||||||
[CompletionResult]::new('--no-progress', 'no-progress', [CompletionResultType]::ParameterName, 'Disable the progress indication.')
|
[CompletionResult]::new('--no-progress', 'no-progress', [CompletionResultType]::ParameterName, 'Disable the progress indication.')
|
||||||
|
[CompletionResult]::new('--print-errors', 'print-errors', [CompletionResultType]::ParameterName, 'Print path with errors.')
|
||||||
[CompletionResult]::new('-D', 'D ', [CompletionResultType]::ParameterName, 'Only directories will be displayed.')
|
[CompletionResult]::new('-D', 'D ', [CompletionResultType]::ParameterName, 'Only directories will be displayed.')
|
||||||
[CompletionResult]::new('--only-dir', 'only-dir', [CompletionResultType]::ParameterName, 'Only directories will be displayed.')
|
[CompletionResult]::new('--only-dir', 'only-dir', [CompletionResultType]::ParameterName, 'Only directories will be displayed.')
|
||||||
[CompletionResult]::new('-F', 'F ', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)')
|
[CompletionResult]::new('-F', 'F ', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)')
|
||||||
[CompletionResult]::new('--only-file', 'only-file', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)')
|
[CompletionResult]::new('--only-file', 'only-file', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)')
|
||||||
|
[CompletionResult]::new('-j', 'j', [CompletionResultType]::ParameterName, 'Output the directory tree as json to the current directory')
|
||||||
|
[CompletionResult]::new('--output-json', 'output-json', [CompletionResultType]::ParameterName, 'Output the directory tree as json to the current directory')
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
|
[CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
|
|||||||
+61
-3
@@ -19,7 +19,7 @@ _dust() {
|
|||||||
|
|
||||||
case "${cmd}" in
|
case "${cmd}" in
|
||||||
dust)
|
dust)
|
||||||
opts="-d -n -p -X -I -L -x -s -r -c -C -b -B -z -R -f -i -v -e -t -w -P -D -F -o -S -h -V --depth --number-of-lines --full-paths --ignore-directory --ignore-all-in-file --dereference-links --limit-filesystem --apparent-size --reverse --no-colors --force-colors --no-percent-bars --bars-on-right --min-size --screen-reader --skip-total --filecount --ignore_hidden --invert-filter --filter --file_types --terminal_width --no-progress --only-dir --only-file --output-format --stack-size --help --version [params]..."
|
opts="-d -T -n -p -X -I -L -x -s -r -c -C -b -B -z -R -f -i -v -e -t -w -P -D -F -o -S -j -M -A -y -h -V --depth --threads --number-of-lines --full-paths --ignore-directory --ignore-all-in-file --dereference-links --limit-filesystem --apparent-size --reverse --no-colors --force-colors --no-percent-bars --bars-on-right --min-size --screen-reader --skip-total --filecount --ignore_hidden --invert-filter --filter --file_types --terminal_width --no-progress --print-errors --only-dir --only-file --output-format --stack-size --output-json --mtime --atime --ctime --files0-from --help --version [PATH]..."
|
||||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||||
return 0
|
return 0
|
||||||
@@ -33,6 +33,14 @@ _dust() {
|
|||||||
COMPREPLY=($(compgen -f "${cur}"))
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
--threads)
|
||||||
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-T)
|
||||||
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
--number-of-lines)
|
--number-of-lines)
|
||||||
COMPREPLY=($(compgen -f "${cur}"))
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
@@ -50,11 +58,33 @@ _dust() {
|
|||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--ignore-all-in-file)
|
--ignore-all-in-file)
|
||||||
|
local oldifs
|
||||||
|
if [[ -v IFS ]]; then
|
||||||
|
oldifs="$IFS"
|
||||||
|
fi
|
||||||
|
IFS=$'\n'
|
||||||
COMPREPLY=($(compgen -f "${cur}"))
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
if [[ -v oldifs ]]; then
|
||||||
|
IFS="$oldifs"
|
||||||
|
fi
|
||||||
|
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
|
||||||
|
compopt -o filenames
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
-I)
|
-I)
|
||||||
|
local oldifs
|
||||||
|
if [[ -v IFS ]]; then
|
||||||
|
oldifs="$IFS"
|
||||||
|
fi
|
||||||
|
IFS=$'\n'
|
||||||
COMPREPLY=($(compgen -f "${cur}"))
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
if [[ -v oldifs ]]; then
|
||||||
|
IFS="$oldifs"
|
||||||
|
fi
|
||||||
|
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
|
||||||
|
compopt -o filenames
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--min-size)
|
--min-size)
|
||||||
@@ -90,11 +120,11 @@ _dust() {
|
|||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--output-format)
|
--output-format)
|
||||||
COMPREPLY=($(compgen -f "${cur}"))
|
COMPREPLY=($(compgen -W "si b k m g t kb mb gb tb" -- "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
-o)
|
-o)
|
||||||
COMPREPLY=($(compgen -f "${cur}"))
|
COMPREPLY=($(compgen -W "si b k m g t kb mb gb tb" -- "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--stack-size)
|
--stack-size)
|
||||||
@@ -105,6 +135,34 @@ _dust() {
|
|||||||
COMPREPLY=($(compgen -f "${cur}"))
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
--mtime)
|
||||||
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-M)
|
||||||
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--atime)
|
||||||
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-A)
|
||||||
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--ctime)
|
||||||
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-y)
|
||||||
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--files0-from)
|
||||||
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
;;
|
;;
|
||||||
|
|||||||
+14
-2
@@ -20,6 +20,8 @@ set edit:completion:arg-completer[dust] = {|@words|
|
|||||||
&'dust'= {
|
&'dust'= {
|
||||||
cand -d 'Depth to show'
|
cand -d 'Depth to show'
|
||||||
cand --depth 'Depth to show'
|
cand --depth 'Depth to show'
|
||||||
|
cand -T 'Number of threads to use'
|
||||||
|
cand --threads 'Number of threads to use'
|
||||||
cand -n 'Number of lines of output to show. (Default is terminal_height - 10)'
|
cand -n 'Number of lines of output to show. (Default is terminal_height - 10)'
|
||||||
cand --number-of-lines 'Number of lines of output to show. (Default is terminal_height - 10)'
|
cand --number-of-lines 'Number of lines of output to show. (Default is terminal_height - 10)'
|
||||||
cand -X 'Exclude any file or directory with this name'
|
cand -X 'Exclude any file or directory with this name'
|
||||||
@@ -34,10 +36,17 @@ set edit:completion:arg-completer[dust] = {|@words|
|
|||||||
cand --filter 'Only include filepaths matching this regex. For png files type: -e "\.png$" '
|
cand --filter 'Only include filepaths matching this regex. For png files type: -e "\.png$" '
|
||||||
cand -w 'Specify width of output overriding the auto detection of terminal width'
|
cand -w 'Specify width of output overriding the auto detection of terminal width'
|
||||||
cand --terminal_width 'Specify width of output overriding the auto detection of terminal width'
|
cand --terminal_width 'Specify width of output overriding the auto detection of terminal width'
|
||||||
cand -o 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size'
|
cand -o 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.'
|
||||||
cand --output-format 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size'
|
cand --output-format 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.'
|
||||||
cand -S 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)'
|
cand -S 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)'
|
||||||
cand --stack-size 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)'
|
cand --stack-size 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)'
|
||||||
|
cand -M '+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)'
|
||||||
|
cand --mtime '+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)'
|
||||||
|
cand -A 'just like -mtime, but based on file access time'
|
||||||
|
cand --atime 'just like -mtime, but based on file access time'
|
||||||
|
cand -y 'just like -mtime, but based on file change time'
|
||||||
|
cand --ctime 'just like -mtime, but based on file change time'
|
||||||
|
cand --files0-from 'run dust on NUL-terminated file names specified in file; if argument is -, then read names from standard input'
|
||||||
cand -p 'Subdirectories will not have their path shortened'
|
cand -p 'Subdirectories will not have their path shortened'
|
||||||
cand --full-paths 'Subdirectories will not have their path shortened'
|
cand --full-paths 'Subdirectories will not have their path shortened'
|
||||||
cand -L 'dereference sym links - Treat sym links as directories and go into them'
|
cand -L 'dereference sym links - Treat sym links as directories and go into them'
|
||||||
@@ -67,10 +76,13 @@ set edit:completion:arg-completer[dust] = {|@words|
|
|||||||
cand --file_types 'show only these file types'
|
cand --file_types 'show only these file types'
|
||||||
cand -P 'Disable the progress indication.'
|
cand -P 'Disable the progress indication.'
|
||||||
cand --no-progress 'Disable the progress indication.'
|
cand --no-progress 'Disable the progress indication.'
|
||||||
|
cand --print-errors 'Print path with errors.'
|
||||||
cand -D 'Only directories will be displayed.'
|
cand -D 'Only directories will be displayed.'
|
||||||
cand --only-dir 'Only directories will be displayed.'
|
cand --only-dir 'Only directories will be displayed.'
|
||||||
cand -F 'Only files will be displayed. (Finds your largest files)'
|
cand -F 'Only files will be displayed. (Finds your largest files)'
|
||||||
cand --only-file 'Only files will be displayed. (Finds your largest files)'
|
cand --only-file 'Only files will be displayed. (Finds your largest files)'
|
||||||
|
cand -j 'Output the directory tree as json to the current directory'
|
||||||
|
cand --output-json 'Output the directory tree as json to the current directory'
|
||||||
cand -h 'Print help'
|
cand -h 'Print help'
|
||||||
cand --help 'Print help'
|
cand --help 'Print help'
|
||||||
cand -V 'Print version'
|
cand -V 'Print version'
|
||||||
|
|||||||
+10
-3
@@ -1,13 +1,18 @@
|
|||||||
complete -c dust -s d -l depth -d 'Depth to show' -r
|
complete -c dust -s d -l depth -d 'Depth to show' -r
|
||||||
|
complete -c dust -s T -l threads -d 'Number of threads to use' -r
|
||||||
complete -c dust -s n -l number-of-lines -d 'Number of lines of output to show. (Default is terminal_height - 10)' -r
|
complete -c dust -s n -l number-of-lines -d 'Number of lines of output to show. (Default is terminal_height - 10)' -r
|
||||||
complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this name' -r
|
complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this name' -r -F
|
||||||
complete -c dust -s I -l ignore-all-in-file -d 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter' -r
|
complete -c dust -s I -l ignore-all-in-file -d 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter' -r -F
|
||||||
complete -c dust -s z -l min-size -d 'Minimum size file to include in output' -r
|
complete -c dust -s z -l min-size -d 'Minimum size file to include in output' -r
|
||||||
complete -c dust -s v -l invert-filter -d 'Exclude filepaths matching this regex. To ignore png files type: -v "\\.png$" ' -r
|
complete -c dust -s v -l invert-filter -d 'Exclude filepaths matching this regex. To ignore png files type: -v "\\.png$" ' -r
|
||||||
complete -c dust -s e -l filter -d 'Only include filepaths matching this regex. For png files type: -e "\\.png$" ' -r
|
complete -c dust -s e -l filter -d 'Only include filepaths matching this regex. For png files type: -e "\\.png$" ' -r
|
||||||
complete -c dust -s w -l terminal_width -d 'Specify width of output overriding the auto detection of terminal width' -r
|
complete -c dust -s w -l terminal_width -d 'Specify width of output overriding the auto detection of terminal width' -r
|
||||||
complete -c dust -s o -l output-format -d 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size' -r
|
complete -c dust -s o -l output-format -d 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.' -r -f -a "{si '',b '',k '',m '',g '',t '',kb '',mb '',gb '',tb ''}"
|
||||||
complete -c dust -s S -l stack-size -d 'Specify memory to use as stack size - use if you see: \'fatal runtime error: stack overflow\' (default low memory=1048576, high memory=1073741824)' -r
|
complete -c dust -s S -l stack-size -d 'Specify memory to use as stack size - use if you see: \'fatal runtime error: stack overflow\' (default low memory=1048576, high memory=1073741824)' -r
|
||||||
|
complete -c dust -s M -l mtime -d '+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)' -r
|
||||||
|
complete -c dust -s A -l atime -d 'just like -mtime, but based on file access time' -r
|
||||||
|
complete -c dust -s y -l ctime -d 'just like -mtime, but based on file change time' -r
|
||||||
|
complete -c dust -l files0-from -d 'run dust on NUL-terminated file names specified in file; if argument is -, then read names from standard input' -r -F
|
||||||
complete -c dust -s p -l full-paths -d 'Subdirectories will not have their path shortened'
|
complete -c dust -s p -l full-paths -d 'Subdirectories will not have their path shortened'
|
||||||
complete -c dust -s L -l dereference-links -d 'dereference sym links - Treat sym links as directories and go into them'
|
complete -c dust -s L -l dereference-links -d 'dereference sym links - Treat sym links as directories and go into them'
|
||||||
complete -c dust -s x -l limit-filesystem -d 'Only count the files and directories on the same filesystem as the supplied directory'
|
complete -c dust -s x -l limit-filesystem -d 'Only count the files and directories on the same filesystem as the supplied directory'
|
||||||
@@ -23,7 +28,9 @@ complete -c dust -s f -l filecount -d 'Directory \'size\' is number of child fil
|
|||||||
complete -c dust -s i -l ignore_hidden -d 'Do not display hidden files'
|
complete -c dust -s i -l ignore_hidden -d 'Do not display hidden files'
|
||||||
complete -c dust -s t -l file_types -d 'show only these file types'
|
complete -c dust -s t -l file_types -d 'show only these file types'
|
||||||
complete -c dust -s P -l no-progress -d 'Disable the progress indication.'
|
complete -c dust -s P -l no-progress -d 'Disable the progress indication.'
|
||||||
|
complete -c dust -l print-errors -d 'Print path with errors.'
|
||||||
complete -c dust -s D -l only-dir -d 'Only directories will be displayed.'
|
complete -c dust -s D -l only-dir -d 'Only directories will be displayed.'
|
||||||
complete -c dust -s F -l only-file -d 'Only files will be displayed. (Finds your largest files)'
|
complete -c dust -s F -l only-file -d 'Only files will be displayed. (Finds your largest files)'
|
||||||
|
complete -c dust -s j -l output-json -d 'Output the directory tree as json to the current directory'
|
||||||
complete -c dust -s h -l help -d 'Print help'
|
complete -c dust -s h -l help -d 'Print help'
|
||||||
complete -c dust -s V -l version -d 'Print version'
|
complete -c dust -s V -l version -d 'Print version'
|
||||||
|
|||||||
+40
-15
@@ -1,27 +1,30 @@
|
|||||||
.ie \n(.g .ds Aq \(aq
|
.ie \n(.g .ds Aq \(aq
|
||||||
.el .ds Aq '
|
.el .ds Aq '
|
||||||
.TH Dust 1 "Dust 0.9.0"
|
.TH Dust 1 "Dust 1.1.0"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Dust \- Like du but more intuitive
|
Dust \- Like du but more intuitive
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
\fBdust\fR [\fB\-d\fR|\fB\-\-depth\fR] [\fB\-n\fR|\fB\-\-number\-of\-lines\fR] [\fB\-p\fR|\fB\-\-full\-paths\fR] [\fB\-X\fR|\fB\-\-ignore\-directory\fR] [\fB\-I\fR|\fB\-\-ignore\-all\-in\-file\fR] [\fB\-L\fR|\fB\-\-dereference\-links\fR] [\fB\-x\fR|\fB\-\-limit\-filesystem\fR] [\fB\-s\fR|\fB\-\-apparent\-size\fR] [\fB\-r\fR|\fB\-\-reverse\fR] [\fB\-c\fR|\fB\-\-no\-colors\fR] [\fB\-C\fR|\fB\-\-force\-colors\fR] [\fB\-b\fR|\fB\-\-no\-percent\-bars\fR] [\fB\-B\fR|\fB\-\-bars\-on\-right\fR] [\fB\-z\fR|\fB\-\-min\-size\fR] [\fB\-R\fR|\fB\-\-screen\-reader\fR] [\fB\-\-skip\-total\fR] [\fB\-f\fR|\fB\-\-filecount\fR] [\fB\-i\fR|\fB\-\-ignore_hidden\fR] [\fB\-v\fR|\fB\-\-invert\-filter\fR] [\fB\-e\fR|\fB\-\-filter\fR] [\fB\-t\fR|\fB\-\-file_types\fR] [\fB\-w\fR|\fB\-\-terminal_width\fR] [\fB\-P\fR|\fB\-\-no\-progress\fR] [\fB\-D\fR|\fB\-\-only\-dir\fR] [\fB\-F\fR|\fB\-\-only\-file\fR] [\fB\-o\fR|\fB\-\-output\-format\fR] [\fB\-S\fR|\fB\-\-stack\-size\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIparams\fR]
|
\fBdust\fR [\fB\-d\fR|\fB\-\-depth\fR] [\fB\-T\fR|\fB\-\-threads\fR] [\fB\-n\fR|\fB\-\-number\-of\-lines\fR] [\fB\-p\fR|\fB\-\-full\-paths\fR] [\fB\-X\fR|\fB\-\-ignore\-directory\fR] [\fB\-I\fR|\fB\-\-ignore\-all\-in\-file\fR] [\fB\-L\fR|\fB\-\-dereference\-links\fR] [\fB\-x\fR|\fB\-\-limit\-filesystem\fR] [\fB\-s\fR|\fB\-\-apparent\-size\fR] [\fB\-r\fR|\fB\-\-reverse\fR] [\fB\-c\fR|\fB\-\-no\-colors\fR] [\fB\-C\fR|\fB\-\-force\-colors\fR] [\fB\-b\fR|\fB\-\-no\-percent\-bars\fR] [\fB\-B\fR|\fB\-\-bars\-on\-right\fR] [\fB\-z\fR|\fB\-\-min\-size\fR] [\fB\-R\fR|\fB\-\-screen\-reader\fR] [\fB\-\-skip\-total\fR] [\fB\-f\fR|\fB\-\-filecount\fR] [\fB\-i\fR|\fB\-\-ignore_hidden\fR] [\fB\-v\fR|\fB\-\-invert\-filter\fR] [\fB\-e\fR|\fB\-\-filter\fR] [\fB\-t\fR|\fB\-\-file_types\fR] [\fB\-w\fR|\fB\-\-terminal_width\fR] [\fB\-P\fR|\fB\-\-no\-progress\fR] [\fB\-\-print\-errors\fR] [\fB\-D\fR|\fB\-\-only\-dir\fR] [\fB\-F\fR|\fB\-\-only\-file\fR] [\fB\-o\fR|\fB\-\-output\-format\fR] [\fB\-S\fR|\fB\-\-stack\-size\fR] [\fB\-j\fR|\fB\-\-output\-json\fR] [\fB\-M\fR|\fB\-\-mtime\fR] [\fB\-A\fR|\fB\-\-atime\fR] [\fB\-y\fR|\fB\-\-ctime\fR] [\fB\-\-files0\-from\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIPATH\fR]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Like du but more intuitive
|
Like du but more intuitive
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
\fB\-d\fR, \fB\-\-depth\fR
|
\fB\-d\fR, \fB\-\-depth\fR=\fIDEPTH\fR
|
||||||
Depth to show
|
Depth to show
|
||||||
.TP
|
.TP
|
||||||
\fB\-n\fR, \fB\-\-number\-of\-lines\fR
|
\fB\-T\fR, \fB\-\-threads\fR
|
||||||
|
Number of threads to use
|
||||||
|
.TP
|
||||||
|
\fB\-n\fR, \fB\-\-number\-of\-lines\fR=\fINUMBER\fR
|
||||||
Number of lines of output to show. (Default is terminal_height \- 10)
|
Number of lines of output to show. (Default is terminal_height \- 10)
|
||||||
.TP
|
.TP
|
||||||
\fB\-p\fR, \fB\-\-full\-paths\fR
|
\fB\-p\fR, \fB\-\-full\-paths\fR
|
||||||
Subdirectories will not have their path shortened
|
Subdirectories will not have their path shortened
|
||||||
.TP
|
.TP
|
||||||
\fB\-X\fR, \fB\-\-ignore\-directory\fR
|
\fB\-X\fR, \fB\-\-ignore\-directory\fR=\fIPATH\fR
|
||||||
Exclude any file or directory with this name
|
Exclude any file or directory with this name
|
||||||
.TP
|
.TP
|
||||||
\fB\-I\fR, \fB\-\-ignore\-all\-in\-file\fR
|
\fB\-I\fR, \fB\-\-ignore\-all\-in\-file\fR=\fIFILE\fR
|
||||||
Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by \-\-invert_filter
|
Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by \-\-invert_filter
|
||||||
.TP
|
.TP
|
||||||
\fB\-L\fR, \fB\-\-dereference\-links\fR
|
\fB\-L\fR, \fB\-\-dereference\-links\fR
|
||||||
@@ -48,7 +51,7 @@ No percent bars or percentages will be displayed
|
|||||||
\fB\-B\fR, \fB\-\-bars\-on\-right\fR
|
\fB\-B\fR, \fB\-\-bars\-on\-right\fR
|
||||||
percent bars moved to right side of screen
|
percent bars moved to right side of screen
|
||||||
.TP
|
.TP
|
||||||
\fB\-z\fR, \fB\-\-min\-size\fR
|
\fB\-z\fR, \fB\-\-min\-size\fR=\fIMIN_SIZE\fR
|
||||||
Minimum size file to include in output
|
Minimum size file to include in output
|
||||||
.TP
|
.TP
|
||||||
\fB\-R\fR, \fB\-\-screen\-reader\fR
|
\fB\-R\fR, \fB\-\-screen\-reader\fR
|
||||||
@@ -63,40 +66,62 @@ Directory \*(Aqsize\*(Aq is number of child files instead of disk size
|
|||||||
\fB\-i\fR, \fB\-\-ignore_hidden\fR
|
\fB\-i\fR, \fB\-\-ignore_hidden\fR
|
||||||
Do not display hidden files
|
Do not display hidden files
|
||||||
.TP
|
.TP
|
||||||
\fB\-v\fR, \fB\-\-invert\-filter\fR
|
\fB\-v\fR, \fB\-\-invert\-filter\fR=\fIREGEX\fR
|
||||||
Exclude filepaths matching this regex. To ignore png files type: \-v "\\.png$"
|
Exclude filepaths matching this regex. To ignore png files type: \-v "\\.png$"
|
||||||
.TP
|
.TP
|
||||||
\fB\-e\fR, \fB\-\-filter\fR
|
\fB\-e\fR, \fB\-\-filter\fR=\fIREGEX\fR
|
||||||
Only include filepaths matching this regex. For png files type: \-e "\\.png$"
|
Only include filepaths matching this regex. For png files type: \-e "\\.png$"
|
||||||
.TP
|
.TP
|
||||||
\fB\-t\fR, \fB\-\-file_types\fR
|
\fB\-t\fR, \fB\-\-file_types\fR
|
||||||
show only these file types
|
show only these file types
|
||||||
.TP
|
.TP
|
||||||
\fB\-w\fR, \fB\-\-terminal_width\fR
|
\fB\-w\fR, \fB\-\-terminal_width\fR=\fIWIDTH\fR
|
||||||
Specify width of output overriding the auto detection of terminal width
|
Specify width of output overriding the auto detection of terminal width
|
||||||
.TP
|
.TP
|
||||||
\fB\-P\fR, \fB\-\-no\-progress\fR
|
\fB\-P\fR, \fB\-\-no\-progress\fR
|
||||||
Disable the progress indication.
|
Disable the progress indication.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-print\-errors\fR
|
||||||
|
Print path with errors.
|
||||||
|
.TP
|
||||||
\fB\-D\fR, \fB\-\-only\-dir\fR
|
\fB\-D\fR, \fB\-\-only\-dir\fR
|
||||||
Only directories will be displayed.
|
Only directories will be displayed.
|
||||||
.TP
|
.TP
|
||||||
\fB\-F\fR, \fB\-\-only\-file\fR
|
\fB\-F\fR, \fB\-\-only\-file\fR
|
||||||
Only files will be displayed. (Finds your largest files)
|
Only files will be displayed. (Finds your largest files)
|
||||||
.TP
|
.TP
|
||||||
\fB\-o\fR, \fB\-\-output\-format\fR
|
\fB\-o\fR, \fB\-\-output\-format\fR=\fIFORMAT\fR
|
||||||
Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size
|
Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
[\fIpossible values: \fRsi, b, k, m, g, t, kb, mb, gb, tb]
|
||||||
.TP
|
.TP
|
||||||
\fB\-S\fR, \fB\-\-stack\-size\fR
|
\fB\-S\fR, \fB\-\-stack\-size\fR=\fISTACK_SIZE\fR
|
||||||
Specify memory to use as stack size \- use if you see: \*(Aqfatal runtime error: stack overflow\*(Aq (default low memory=1048576, high memory=1073741824)
|
Specify memory to use as stack size \- use if you see: \*(Aqfatal runtime error: stack overflow\*(Aq (default low memory=1048576, high memory=1073741824)
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-j\fR, \fB\-\-output\-json\fR
|
||||||
|
Output the directory tree as json to the current directory
|
||||||
|
.TP
|
||||||
|
\fB\-M\fR, \fB\-\-mtime\fR
|
||||||
|
+/\-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and \-n => (𝑐𝑢𝑟𝑟−𝑛, +∞)
|
||||||
|
.TP
|
||||||
|
\fB\-A\fR, \fB\-\-atime\fR
|
||||||
|
just like \-mtime, but based on file access time
|
||||||
|
.TP
|
||||||
|
\fB\-y\fR, \fB\-\-ctime\fR
|
||||||
|
just like \-mtime, but based on file change time
|
||||||
|
.TP
|
||||||
|
\fB\-\-files0\-from\fR
|
||||||
|
run dust on NUL\-terminated file names specified in file; if argument is \-, then read names from standard input
|
||||||
|
.TP
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
Print help
|
Print help
|
||||||
.TP
|
.TP
|
||||||
\fB\-V\fR, \fB\-\-version\fR
|
\fB\-V\fR, \fB\-\-version\fR
|
||||||
Print version
|
Print version
|
||||||
.TP
|
.TP
|
||||||
[\fIparams\fR]
|
[\fIPATH\fR]
|
||||||
|
|
||||||
.SH VERSION
|
.SH VERSION
|
||||||
v0.9.0
|
v1.1.0
|
||||||
|
|||||||
+92
-8
@@ -1,4 +1,4 @@
|
|||||||
use clap::{value_parser, Arg, Command};
|
use clap::{builder::PossibleValue, value_parser, Arg, Command};
|
||||||
|
|
||||||
// For single thread mode set this variable on your command line:
|
// For single thread mode set this variable on your command line:
|
||||||
// export RAYON_NUM_THREADS=1
|
// export RAYON_NUM_THREADS=1
|
||||||
@@ -7,19 +7,28 @@ pub fn build_cli() -> Command {
|
|||||||
Command::new("Dust")
|
Command::new("Dust")
|
||||||
.about("Like du but more intuitive")
|
.about("Like du but more intuitive")
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
.version(env!("CARGO_PKG_VERSION"))
|
||||||
.trailing_var_arg(true)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("depth")
|
Arg::new("depth")
|
||||||
.short('d')
|
.short('d')
|
||||||
.long("depth")
|
.long("depth")
|
||||||
|
.value_name("DEPTH")
|
||||||
.value_parser(value_parser!(usize))
|
.value_parser(value_parser!(usize))
|
||||||
.help("Depth to show")
|
.help("Depth to show")
|
||||||
.num_args(1)
|
.num_args(1)
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("threads")
|
||||||
|
.short('T')
|
||||||
|
.long("threads")
|
||||||
|
.value_parser(value_parser!(usize))
|
||||||
|
.help("Number of threads to use")
|
||||||
|
.num_args(1)
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("number_of_lines")
|
Arg::new("number_of_lines")
|
||||||
.short('n')
|
.short('n')
|
||||||
.long("number-of-lines")
|
.long("number-of-lines")
|
||||||
|
.value_name("NUMBER")
|
||||||
.value_parser(value_parser!(usize))
|
.value_parser(value_parser!(usize))
|
||||||
.help("Number of lines of output to show. (Default is terminal_height - 10)")
|
.help("Number of lines of output to show. (Default is terminal_height - 10)")
|
||||||
.num_args(1)
|
.num_args(1)
|
||||||
@@ -35,6 +44,8 @@ pub fn build_cli() -> Command {
|
|||||||
Arg::new("ignore_directory")
|
Arg::new("ignore_directory")
|
||||||
.short('X')
|
.short('X')
|
||||||
.long("ignore-directory")
|
.long("ignore-directory")
|
||||||
|
.value_name("PATH")
|
||||||
|
.value_hint(clap::ValueHint::AnyPath)
|
||||||
.action(clap::ArgAction::Append)
|
.action(clap::ArgAction::Append)
|
||||||
.help("Exclude any file or directory with this name"),
|
.help("Exclude any file or directory with this name"),
|
||||||
)
|
)
|
||||||
@@ -42,6 +53,8 @@ pub fn build_cli() -> Command {
|
|||||||
Arg::new("ignore_all_in_file")
|
Arg::new("ignore_all_in_file")
|
||||||
.short('I')
|
.short('I')
|
||||||
.long("ignore-all-in-file")
|
.long("ignore-all-in-file")
|
||||||
|
.value_name("FILE")
|
||||||
|
.value_hint(clap::ValueHint::FilePath)
|
||||||
.value_parser(value_parser!(String))
|
.value_parser(value_parser!(String))
|
||||||
.help("Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter"),
|
.help("Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter"),
|
||||||
)
|
)
|
||||||
@@ -105,6 +118,7 @@ pub fn build_cli() -> Command {
|
|||||||
Arg::new("min_size")
|
Arg::new("min_size")
|
||||||
.short('z')
|
.short('z')
|
||||||
.long("min-size")
|
.long("min-size")
|
||||||
|
.value_name("MIN_SIZE")
|
||||||
.num_args(1)
|
.num_args(1)
|
||||||
.help("Minimum size file to include in output"),
|
.help("Minimum size file to include in output"),
|
||||||
)
|
)
|
||||||
@@ -139,6 +153,7 @@ pub fn build_cli() -> Command {
|
|||||||
Arg::new("invert_filter")
|
Arg::new("invert_filter")
|
||||||
.short('v')
|
.short('v')
|
||||||
.long("invert-filter")
|
.long("invert-filter")
|
||||||
|
.value_name("REGEX")
|
||||||
.action(clap::ArgAction::Append)
|
.action(clap::ArgAction::Append)
|
||||||
.conflicts_with("filter")
|
.conflicts_with("filter")
|
||||||
.conflicts_with("types")
|
.conflicts_with("types")
|
||||||
@@ -148,6 +163,7 @@ pub fn build_cli() -> Command {
|
|||||||
Arg::new("filter")
|
Arg::new("filter")
|
||||||
.short('e')
|
.short('e')
|
||||||
.long("filter")
|
.long("filter")
|
||||||
|
.value_name("REGEX")
|
||||||
.action(clap::ArgAction::Append)
|
.action(clap::ArgAction::Append)
|
||||||
.conflicts_with("types")
|
.conflicts_with("types")
|
||||||
.help("Only include filepaths matching this regex. For png files type: -e \"\\.png$\" "),
|
.help("Only include filepaths matching this regex. For png files type: -e \"\\.png$\" "),
|
||||||
@@ -165,8 +181,9 @@ pub fn build_cli() -> Command {
|
|||||||
Arg::new("width")
|
Arg::new("width")
|
||||||
.short('w')
|
.short('w')
|
||||||
.long("terminal_width")
|
.long("terminal_width")
|
||||||
.num_args(1)
|
.value_name("WIDTH")
|
||||||
.value_parser(value_parser!(usize))
|
.value_parser(value_parser!(usize))
|
||||||
|
.num_args(1)
|
||||||
.help("Specify width of output overriding the auto detection of terminal width"),
|
.help("Specify width of output overriding the auto detection of terminal width"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
@@ -176,6 +193,12 @@ pub fn build_cli() -> Command {
|
|||||||
.action(clap::ArgAction::SetTrue)
|
.action(clap::ArgAction::SetTrue)
|
||||||
.help("Disable the progress indication."),
|
.help("Disable the progress indication."),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("print_errors")
|
||||||
|
.long("print-errors")
|
||||||
|
.action(clap::ArgAction::SetTrue)
|
||||||
|
.help("Print path with errors."),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("only_dir")
|
Arg::new("only_dir")
|
||||||
.short('D')
|
.short('D')
|
||||||
@@ -197,17 +220,78 @@ pub fn build_cli() -> Command {
|
|||||||
Arg::new("output_format")
|
Arg::new("output_format")
|
||||||
.short('o')
|
.short('o')
|
||||||
.long("output-format")
|
.long("output-format")
|
||||||
.value_parser(value_parser!(String))
|
.value_name("FORMAT")
|
||||||
.help("Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size")
|
.value_parser([
|
||||||
|
PossibleValue::new("si"),
|
||||||
|
PossibleValue::new("b"),
|
||||||
|
PossibleValue::new("k").alias("kib"),
|
||||||
|
PossibleValue::new("m").alias("mib"),
|
||||||
|
PossibleValue::new("g").alias("gib"),
|
||||||
|
PossibleValue::new("t").alias("tib"),
|
||||||
|
PossibleValue::new("kb"),
|
||||||
|
PossibleValue::new("mb"),
|
||||||
|
PossibleValue::new("gb"),
|
||||||
|
PossibleValue::new("tb"),
|
||||||
|
])
|
||||||
|
.ignore_case(true)
|
||||||
|
.help("Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.")
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("stack_size")
|
Arg::new("stack_size")
|
||||||
.short('S')
|
.short('S')
|
||||||
.long("stack-size")
|
.long("stack-size")
|
||||||
.num_args(1)
|
.value_name("STACK_SIZE")
|
||||||
.value_parser(value_parser!(usize))
|
.value_parser(value_parser!(usize))
|
||||||
|
.num_args(1)
|
||||||
.help("Specify memory to use as stack size - use if you see: 'fatal runtime error: stack overflow' (default low memory=1048576, high memory=1073741824)"),
|
.help("Specify memory to use as stack size - use if you see: 'fatal runtime error: stack overflow' (default low memory=1048576, high memory=1073741824)"),
|
||||||
)
|
)
|
||||||
.arg(Arg::new("params").num_args(1..)
|
.arg(
|
||||||
.value_parser(value_parser!(String)))
|
Arg::new("params")
|
||||||
|
.value_name("PATH")
|
||||||
|
.value_hint(clap::ValueHint::AnyPath)
|
||||||
|
.value_parser(value_parser!(String))
|
||||||
|
.num_args(1..)
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("output_json")
|
||||||
|
.short('j')
|
||||||
|
.long("output-json")
|
||||||
|
.action(clap::ArgAction::SetTrue)
|
||||||
|
.help("Output the directory tree as json to the current directory"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("mtime")
|
||||||
|
.short('M')
|
||||||
|
.long("mtime")
|
||||||
|
.num_args(1)
|
||||||
|
.allow_hyphen_values(true)
|
||||||
|
.value_parser(value_parser!(String))
|
||||||
|
.help("+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)")
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("atime")
|
||||||
|
.short('A')
|
||||||
|
.long("atime")
|
||||||
|
.num_args(1)
|
||||||
|
.allow_hyphen_values(true)
|
||||||
|
.value_parser(value_parser!(String))
|
||||||
|
.help("just like -mtime, but based on file access time")
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("ctime")
|
||||||
|
.short('y')
|
||||||
|
.long("ctime")
|
||||||
|
.num_args(1)
|
||||||
|
.allow_hyphen_values(true)
|
||||||
|
.value_parser(value_parser!(String))
|
||||||
|
.help("just like -mtime, but based on file change time")
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("files0_from")
|
||||||
|
.long("files0-from")
|
||||||
|
.value_hint(clap::ValueHint::AnyPath)
|
||||||
|
.value_parser(value_parser!(String))
|
||||||
|
.num_args(1)
|
||||||
|
.help("run dust on NUL-terminated file names specified in file; if argument is -, then read names from standard input"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+108
-11
@@ -1,3 +1,4 @@
|
|||||||
|
use chrono::{Local, TimeZone};
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use config_file::FromConfigFile;
|
use config_file::FromConfigFile;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
@@ -6,8 +7,11 @@ use std::io::IsTerminal;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use crate::dir_walker::Operater;
|
||||||
use crate::display::get_number_format;
|
use crate::display::get_number_format;
|
||||||
|
|
||||||
|
pub static DAY_SECONDS: i64 = 24 * 60 * 60;
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
@@ -29,9 +33,20 @@ pub struct Config {
|
|||||||
pub depth: Option<usize>,
|
pub depth: Option<usize>,
|
||||||
pub bars_on_right: Option<bool>,
|
pub bars_on_right: Option<bool>,
|
||||||
pub stack_size: Option<usize>,
|
pub stack_size: Option<usize>,
|
||||||
|
pub threads: Option<usize>,
|
||||||
|
pub output_json: Option<bool>,
|
||||||
|
pub print_errors: Option<bool>,
|
||||||
|
pub files0_from: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
pub fn get_files_from(&self, options: &ArgMatches) -> Option<String> {
|
||||||
|
let from_file = options.get_one::<String>("files0_from");
|
||||||
|
match from_file {
|
||||||
|
None => self.files0_from.as_ref().map(|x| x.to_string()),
|
||||||
|
Some(x) => Some(x.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn get_no_colors(&self, options: &ArgMatches) -> bool {
|
pub fn get_no_colors(&self, options: &ArgMatches) -> bool {
|
||||||
Some(true) == self.no_colors || options.get_flag("no_colors")
|
Some(true) == self.no_colors || options.get_flag("no_colors")
|
||||||
}
|
}
|
||||||
@@ -50,10 +65,7 @@ impl Config {
|
|||||||
Some(true) == self.ignore_hidden || options.get_flag("ignore_hidden")
|
Some(true) == self.ignore_hidden || options.get_flag("ignore_hidden")
|
||||||
}
|
}
|
||||||
pub fn get_full_paths(&self, options: &ArgMatches) -> bool {
|
pub fn get_full_paths(&self, options: &ArgMatches) -> bool {
|
||||||
// If we are only showing files, always show full paths
|
Some(true) == self.display_full_paths || options.get_flag("display_full_paths")
|
||||||
Some(true) == self.display_full_paths
|
|
||||||
|| options.get_flag("display_full_paths")
|
|
||||||
|| self.get_only_file(options)
|
|
||||||
}
|
}
|
||||||
pub fn get_reverse(&self, options: &ArgMatches) -> bool {
|
pub fn get_reverse(&self, options: &ArgMatches) -> bool {
|
||||||
Some(true) == self.reverse || options.get_flag("reverse")
|
Some(true) == self.reverse || options.get_flag("reverse")
|
||||||
@@ -103,6 +115,10 @@ impl Config {
|
|||||||
pub fn get_only_dir(&self, options: &ArgMatches) -> bool {
|
pub fn get_only_dir(&self, options: &ArgMatches) -> bool {
|
||||||
Some(true) == self.only_dir || options.get_flag("only_dir")
|
Some(true) == self.only_dir || options.get_flag("only_dir")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_print_errors(&self, options: &ArgMatches) -> bool {
|
||||||
|
Some(true) == self.print_errors || options.get_flag("print_errors")
|
||||||
|
}
|
||||||
pub fn get_only_file(&self, options: &ArgMatches) -> bool {
|
pub fn get_only_file(&self, options: &ArgMatches) -> bool {
|
||||||
Some(true) == self.only_file || options.get_flag("only_file")
|
Some(true) == self.only_file || options.get_flag("only_file")
|
||||||
}
|
}
|
||||||
@@ -117,6 +133,72 @@ impl Config {
|
|||||||
from_cmd_line.copied()
|
from_cmd_line.copied()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn get_threads(&self, options: &ArgMatches) -> Option<usize> {
|
||||||
|
let from_cmd_line = options.get_one::<usize>("threads");
|
||||||
|
if from_cmd_line.is_none() {
|
||||||
|
self.threads
|
||||||
|
} else {
|
||||||
|
from_cmd_line.copied()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn get_output_json(&self, options: &ArgMatches) -> bool {
|
||||||
|
Some(true) == self.output_json || options.get_flag("output_json")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_modified_time_operator(&self, options: &ArgMatches) -> Option<(Operater, i64)> {
|
||||||
|
get_filter_time_operator(
|
||||||
|
options.get_one::<String>("mtime"),
|
||||||
|
get_current_date_epoch_seconds(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_accessed_time_operator(&self, options: &ArgMatches) -> Option<(Operater, i64)> {
|
||||||
|
get_filter_time_operator(
|
||||||
|
options.get_one::<String>("atime"),
|
||||||
|
get_current_date_epoch_seconds(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_created_time_operator(&self, options: &ArgMatches) -> Option<(Operater, i64)> {
|
||||||
|
get_filter_time_operator(
|
||||||
|
options.get_one::<String>("ctime"),
|
||||||
|
get_current_date_epoch_seconds(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_current_date_epoch_seconds() -> i64 {
|
||||||
|
// calcurate current date epoch seconds
|
||||||
|
let now = Local::now();
|
||||||
|
let current_date = now.date_naive();
|
||||||
|
|
||||||
|
let current_date_time = current_date.and_hms_opt(0, 0, 0).unwrap();
|
||||||
|
Local
|
||||||
|
.from_local_datetime(¤t_date_time)
|
||||||
|
.unwrap()
|
||||||
|
.timestamp()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_filter_time_operator(
|
||||||
|
option_value: Option<&String>,
|
||||||
|
current_date_epoch_seconds: i64,
|
||||||
|
) -> Option<(Operater, i64)> {
|
||||||
|
match option_value {
|
||||||
|
Some(val) => {
|
||||||
|
let time = current_date_epoch_seconds
|
||||||
|
- val
|
||||||
|
.parse::<i64>()
|
||||||
|
.unwrap_or_else(|_| panic!("invalid data format"))
|
||||||
|
.abs()
|
||||||
|
* DAY_SECONDS;
|
||||||
|
match val.chars().next().expect("Value should not be empty") {
|
||||||
|
'+' => Some((Operater::LessThan, time - DAY_SECONDS)),
|
||||||
|
'-' => Some((Operater::GreaterThan, time)),
|
||||||
|
_ => Some((Operater::Equal, time - DAY_SECONDS)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_min_size(input: &str) -> Option<usize> {
|
fn convert_min_size(input: &str) -> Option<usize> {
|
||||||
@@ -176,30 +258,45 @@ pub fn get_config() -> Config {
|
|||||||
mod tests {
|
mod tests {
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use chrono::{Datelike, Timelike};
|
||||||
use clap::{value_parser, Arg, ArgMatches, Command};
|
use clap::{value_parser, Arg, ArgMatches, Command};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_current_date_epoch_seconds() {
|
||||||
|
let epoch_seconds = get_current_date_epoch_seconds();
|
||||||
|
let dt = Local.timestamp_opt(epoch_seconds, 0).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(dt.hour(), 0);
|
||||||
|
assert_eq!(dt.minute(), 0);
|
||||||
|
assert_eq!(dt.second(), 0);
|
||||||
|
assert_eq!(dt.date_naive().day(), Local::now().date_naive().day());
|
||||||
|
assert_eq!(dt.date_naive().month(), Local::now().date_naive().month());
|
||||||
|
assert_eq!(dt.date_naive().year(), Local::now().date_naive().year());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_conversion() {
|
fn test_conversion() {
|
||||||
assert_eq!(convert_min_size("55"), Some(55));
|
assert_eq!(convert_min_size("55"), Some(55));
|
||||||
assert_eq!(convert_min_size("12344321"), Some(12344321));
|
assert_eq!(convert_min_size("12344321"), Some(12344321));
|
||||||
assert_eq!(convert_min_size("95RUBBISH"), None);
|
assert_eq!(convert_min_size("95RUBBISH"), None);
|
||||||
assert_eq!(convert_min_size("10K"), Some(10 * 1024));
|
assert_eq!(convert_min_size("10Ki"), Some(10 * 1024));
|
||||||
|
assert_eq!(convert_min_size("10MiB"), Some(10 * 1024usize.pow(2)));
|
||||||
assert_eq!(convert_min_size("10M"), Some(10 * 1024usize.pow(2)));
|
assert_eq!(convert_min_size("10M"), Some(10 * 1024usize.pow(2)));
|
||||||
assert_eq!(convert_min_size("10MiB"), Some(10 * 1000usize.pow(2)));
|
assert_eq!(convert_min_size("10Mb"), Some(10 * 1000usize.pow(2)));
|
||||||
assert_eq!(convert_min_size("2G"), Some(2 * 1024usize.pow(3)));
|
assert_eq!(convert_min_size("2Gi"), Some(2 * 1024usize.pow(3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_min_size_from_config_applied_or_overridden() {
|
fn test_min_size_from_config_applied_or_overridden() {
|
||||||
let c = Config {
|
let c = Config {
|
||||||
min_size: Some("1K".to_owned()),
|
min_size: Some("1KiB".to_owned()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
assert_eq!(c._get_min_size(None), Some(1024));
|
assert_eq!(c._get_min_size(None), Some(1024));
|
||||||
assert_eq!(c._get_min_size(Some(&"2K".into())), Some(2048));
|
assert_eq!(c._get_min_size(Some(&"2KiB".into())), Some(2048));
|
||||||
|
|
||||||
assert_eq!(c._get_min_size(Some(&"1kib".into())), Some(1000));
|
assert_eq!(c._get_min_size(Some(&"1kb".into())), Some(1000));
|
||||||
assert_eq!(c._get_min_size(Some(&"2KiB".into())), Some(2000));
|
assert_eq!(c._get_min_size(Some(&"2KB".into())), Some(2000));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
+123
-53
@@ -1,3 +1,4 @@
|
|||||||
|
use std::cmp::Ordering;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
@@ -7,6 +8,7 @@ use crate::progress::Operation;
|
|||||||
use crate::progress::PAtomicInfo;
|
use crate::progress::PAtomicInfo;
|
||||||
use crate::progress::RuntimeErrors;
|
use crate::progress::RuntimeErrors;
|
||||||
use crate::progress::ORDERING;
|
use crate::progress::ORDERING;
|
||||||
|
use crate::utils::is_filtered_out_due_to_file_time;
|
||||||
use crate::utils::is_filtered_out_due_to_invert_regex;
|
use crate::utils::is_filtered_out_due_to_invert_regex;
|
||||||
use crate::utils::is_filtered_out_due_to_regex;
|
use crate::utils::is_filtered_out_due_to_regex;
|
||||||
use rayon::iter::ParallelBridge;
|
use rayon::iter::ParallelBridge;
|
||||||
@@ -20,11 +22,22 @@ use crate::node::build_node;
|
|||||||
use std::fs::DirEntry;
|
use std::fs::DirEntry;
|
||||||
|
|
||||||
use crate::platform::get_metadata;
|
use crate::platform::get_metadata;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Operater {
|
||||||
|
Equal = 0,
|
||||||
|
LessThan = 1,
|
||||||
|
GreaterThan = 2,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct WalkData<'a> {
|
pub struct WalkData<'a> {
|
||||||
pub ignore_directories: HashSet<PathBuf>,
|
pub ignore_directories: HashSet<PathBuf>,
|
||||||
pub filter_regex: &'a [Regex],
|
pub filter_regex: &'a [Regex],
|
||||||
pub invert_filter_regex: &'a [Regex],
|
pub invert_filter_regex: &'a [Regex],
|
||||||
pub allowed_filesystems: HashSet<u64>,
|
pub allowed_filesystems: HashSet<u64>,
|
||||||
|
pub filter_modified_time: Option<(Operater, i64)>,
|
||||||
|
pub filter_accessed_time: Option<(Operater, i64)>,
|
||||||
|
pub filter_changed_time: Option<(Operater, i64)>,
|
||||||
pub use_apparent_size: bool,
|
pub use_apparent_size: bool,
|
||||||
pub by_filecount: bool,
|
pub by_filecount: bool,
|
||||||
pub ignore_hidden: bool,
|
pub ignore_hidden: bool,
|
||||||
@@ -83,16 +96,20 @@ fn clean_inodes(
|
|||||||
|
|
||||||
fn sort_by_inode(a: &Node, b: &Node) -> std::cmp::Ordering {
|
fn sort_by_inode(a: &Node, b: &Node) -> std::cmp::Ordering {
|
||||||
// Sorting by inode is quicker than by sorting by name/size
|
// Sorting by inode is quicker than by sorting by name/size
|
||||||
if let Some(x) = a.inode_device {
|
match (a.inode_device, b.inode_device) {
|
||||||
if let Some(y) = b.inode_device {
|
(Some(x), Some(y)) => {
|
||||||
if x.0 != y.0 {
|
if x.0 != y.0 {
|
||||||
return x.0.cmp(&y.0);
|
x.0.cmp(&y.0)
|
||||||
} else if x.1 != y.1 {
|
} else if x.1 != y.1 {
|
||||||
return x.1.cmp(&y.1);
|
x.1.cmp(&y.1)
|
||||||
|
} else {
|
||||||
|
a.name.cmp(&b.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
(Some(_), None) => Ordering::Greater,
|
||||||
|
(None, Some(_)) => Ordering::Less,
|
||||||
|
(None, None) => a.name.cmp(&b.name),
|
||||||
}
|
}
|
||||||
a.name.cmp(&b.name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
|
fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
|
||||||
@@ -100,14 +117,34 @@ fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
|
|||||||
let is_ignored_path = walk_data.ignore_directories.contains(&entry.path());
|
let is_ignored_path = walk_data.ignore_directories.contains(&entry.path());
|
||||||
|
|
||||||
if !walk_data.allowed_filesystems.is_empty() {
|
if !walk_data.allowed_filesystems.is_empty() {
|
||||||
let size_inode_device = get_metadata(&entry.path(), false);
|
let size_inode_device = get_metadata(entry.path(), false);
|
||||||
|
if let Some((_size, Some((_id, dev)), _gunk)) = size_inode_device {
|
||||||
if let Some((_size, Some((_id, dev)))) = size_inode_device {
|
|
||||||
if !walk_data.allowed_filesystems.contains(&dev) {
|
if !walk_data.allowed_filesystems.contains(&dev) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if walk_data.filter_accessed_time.is_some()
|
||||||
|
|| walk_data.filter_modified_time.is_some()
|
||||||
|
|| walk_data.filter_changed_time.is_some()
|
||||||
|
{
|
||||||
|
let size_inode_device = get_metadata(entry.path(), false);
|
||||||
|
if let Some((_, _, (modified_time, accessed_time, changed_time))) = size_inode_device {
|
||||||
|
if entry.path().is_file()
|
||||||
|
&& [
|
||||||
|
(&walk_data.filter_modified_time, modified_time),
|
||||||
|
(&walk_data.filter_accessed_time, accessed_time),
|
||||||
|
(&walk_data.filter_changed_time, changed_time),
|
||||||
|
]
|
||||||
|
.iter()
|
||||||
|
.any(|(filter_time, actual_time)| {
|
||||||
|
is_filtered_out_due_to_file_time(filter_time, *actual_time)
|
||||||
|
})
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Keeping `walk_data.filter_regex.is_empty()` is important for performance reasons, it stops unnecessary work
|
// Keeping `walk_data.filter_regex.is_empty()` is important for performance reasons, it stops unnecessary work
|
||||||
if !walk_data.filter_regex.is_empty()
|
if !walk_data.filter_regex.is_empty()
|
||||||
@@ -130,6 +167,7 @@ fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
|
|||||||
fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
||||||
let prog_data = &walk_data.progress_data;
|
let prog_data = &walk_data.progress_data;
|
||||||
let errors = &walk_data.errors;
|
let errors = &walk_data.errors;
|
||||||
|
|
||||||
if errors.lock().unwrap().abort {
|
if errors.lock().unwrap().abort {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@@ -142,44 +180,46 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.par_bridge()
|
.par_bridge()
|
||||||
.filter_map(|entry| {
|
.filter_map(|entry| {
|
||||||
if let Ok(ref entry) = entry {
|
match entry {
|
||||||
// uncommenting the below line gives simpler code but
|
Ok(ref entry) => {
|
||||||
// rayon doesn't parallelize as well giving a 3X performance drop
|
// uncommenting the below line gives simpler code but
|
||||||
// hence we unravel the recursion a bit
|
// rayon doesn't parallelize as well giving a 3X performance drop
|
||||||
|
// hence we unravel the recursion a bit
|
||||||
|
|
||||||
// return walk(entry.path(), walk_data, depth)
|
// return walk(entry.path(), walk_data, depth)
|
||||||
|
|
||||||
if !ignore_file(entry, walk_data) {
|
if !ignore_file(entry, walk_data) {
|
||||||
if let Ok(data) = entry.file_type() {
|
if let Ok(data) = entry.file_type() {
|
||||||
if data.is_dir()
|
if data.is_dir()
|
||||||
|| (walk_data.follow_links && data.is_symlink())
|
|| (walk_data.follow_links && data.is_symlink())
|
||||||
{
|
{
|
||||||
return walk(entry.path(), walk_data, depth + 1);
|
return walk(entry.path(), walk_data, depth + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let node = build_node(
|
||||||
|
entry.path(),
|
||||||
|
vec![],
|
||||||
|
data.is_symlink(),
|
||||||
|
data.is_file(),
|
||||||
|
depth,
|
||||||
|
walk_data,
|
||||||
|
);
|
||||||
|
|
||||||
|
prog_data.num_files.fetch_add(1, ORDERING);
|
||||||
|
if let Some(ref file) = node {
|
||||||
|
prog_data
|
||||||
|
.total_file_size
|
||||||
|
.fetch_add(file.size, ORDERING);
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
let node = build_node(
|
|
||||||
entry.path(),
|
|
||||||
vec![],
|
|
||||||
walk_data.filter_regex,
|
|
||||||
walk_data.invert_filter_regex,
|
|
||||||
walk_data.use_apparent_size,
|
|
||||||
data.is_symlink(),
|
|
||||||
data.is_file(),
|
|
||||||
walk_data.by_filecount,
|
|
||||||
depth,
|
|
||||||
);
|
|
||||||
|
|
||||||
prog_data.num_files.fetch_add(1, ORDERING);
|
|
||||||
if let Some(ref file) = node {
|
|
||||||
prog_data.total_file_size.fetch_add(file.size, ORDERING);
|
|
||||||
}
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
Err(ref failed) => {
|
||||||
let mut editable_error = errors.lock().unwrap();
|
let mut editable_error = errors.lock().unwrap();
|
||||||
editable_error.no_permissions = true
|
editable_error.no_permissions.insert(failed.to_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
})
|
})
|
||||||
@@ -189,7 +229,9 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
|||||||
let mut editable_error = errors.lock().unwrap();
|
let mut editable_error = errors.lock().unwrap();
|
||||||
match failed.kind() {
|
match failed.kind() {
|
||||||
std::io::ErrorKind::PermissionDenied => {
|
std::io::ErrorKind::PermissionDenied => {
|
||||||
editable_error.no_permissions = true;
|
editable_error
|
||||||
|
.no_permissions
|
||||||
|
.insert(dir.to_string_lossy().into());
|
||||||
}
|
}
|
||||||
std::io::ErrorKind::NotFound => {
|
std::io::ErrorKind::NotFound => {
|
||||||
editable_error.file_not_found.insert(failed.to_string());
|
editable_error.file_not_found.insert(failed.to_string());
|
||||||
@@ -209,20 +251,11 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
|||||||
}
|
}
|
||||||
vec![]
|
vec![]
|
||||||
};
|
};
|
||||||
build_node(
|
build_node(dir, children, false, false, depth, walk_data)
|
||||||
dir,
|
|
||||||
children,
|
|
||||||
walk_data.filter_regex,
|
|
||||||
walk_data.invert_filter_regex,
|
|
||||||
walk_data.use_apparent_size,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
walk_data.by_filecount,
|
|
||||||
depth,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -260,4 +293,41 @@ mod tests {
|
|||||||
assert_eq!(clean_inodes(n.clone(), &mut inodes, true), Some(n.clone()));
|
assert_eq!(clean_inodes(n.clone(), &mut inodes, true), Some(n.clone()));
|
||||||
assert_eq!(clean_inodes(n.clone(), &mut inodes, true), Some(n.clone()));
|
assert_eq!(clean_inodes(n.clone(), &mut inodes, true), Some(n.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_total_ordering_of_sort_by_inode() {
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
let a = Node {
|
||||||
|
name: PathBuf::from_str("a").unwrap(),
|
||||||
|
size: 0,
|
||||||
|
children: vec![],
|
||||||
|
inode_device: Some((3, 66310)),
|
||||||
|
depth: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
let b = Node {
|
||||||
|
name: PathBuf::from_str("b").unwrap(),
|
||||||
|
size: 0,
|
||||||
|
children: vec![],
|
||||||
|
inode_device: None,
|
||||||
|
depth: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
let c = Node {
|
||||||
|
name: PathBuf::from_str("c").unwrap(),
|
||||||
|
size: 0,
|
||||||
|
children: vec![],
|
||||||
|
inode_device: Some((1, 66310)),
|
||||||
|
depth: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(sort_by_inode(&a, &b), Ordering::Greater);
|
||||||
|
assert_eq!(sort_by_inode(&a, &c), Ordering::Greater);
|
||||||
|
assert_eq!(sort_by_inode(&c, &b), Ordering::Greater);
|
||||||
|
|
||||||
|
assert_eq!(sort_by_inode(&b, &a), Ordering::Less);
|
||||||
|
assert_eq!(sort_by_inode(&c, &a), Ordering::Less);
|
||||||
|
assert_eq!(sort_by_inode(&b, &c), Ordering::Less);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-13
@@ -411,11 +411,14 @@ fn get_pretty_name(
|
|||||||
|
|
||||||
// If we are working with SI units or not
|
// If we are working with SI units or not
|
||||||
pub fn get_type_of_thousand(output_str: &str) -> u64 {
|
pub fn get_type_of_thousand(output_str: &str) -> u64 {
|
||||||
let is_si = output_str.contains('i'); // si, KiB, MiB, etc
|
if output_str.is_empty() {
|
||||||
if is_si {
|
|
||||||
1000
|
|
||||||
} else {
|
|
||||||
1024
|
1024
|
||||||
|
} else if output_str == "si" {
|
||||||
|
1000
|
||||||
|
} else if output_str.contains('i') || output_str.len() == 1 {
|
||||||
|
1024
|
||||||
|
} else {
|
||||||
|
1000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,23 +555,25 @@ mod tests {
|
|||||||
assert_eq!(human_readable_number(1024 * 100, "si"), "102K");
|
assert_eq!(human_readable_number(1024 * 100, "si"), "102K");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Refer to https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
|
||||||
#[test]
|
#[test]
|
||||||
fn test_human_readable_number_kb() {
|
fn test_human_readable_number_kb() {
|
||||||
let hrn = human_readable_number;
|
let hrn = human_readable_number;
|
||||||
assert_eq!(hrn(1023, "b"), "1023B");
|
assert_eq!(hrn(1023, "b"), "1023B");
|
||||||
assert_eq!(hrn(1000 * 1000, "bytes"), "1000000B");
|
assert_eq!(hrn(1000 * 1000, "bytes"), "1000000B");
|
||||||
assert_eq!(hrn(1023, "kb"), "0K");
|
assert_eq!(hrn(1023, "kb"), "1K");
|
||||||
assert_eq!(hrn(1023, "kib"), "1K");
|
assert_eq!(hrn(1023, "k"), "0K");
|
||||||
assert_eq!(hrn(1024, "kb"), "1K");
|
assert_eq!(hrn(1023, "kib"), "0K");
|
||||||
assert_eq!(hrn(1024 * 512, "kb"), "512K");
|
assert_eq!(hrn(1024, "kib"), "1K");
|
||||||
assert_eq!(hrn(1024 * 1024, "kb"), "1024K");
|
assert_eq!(hrn(1024 * 512, "kib"), "512K");
|
||||||
assert_eq!(hrn(1024 * 1000 * 1000 * 20, "kb"), "20000000K");
|
assert_eq!(hrn(1024 * 1024, "kib"), "1024K");
|
||||||
assert_eq!(hrn(1024 * 1024 * 1000 * 20, "mb"), "20000M");
|
assert_eq!(hrn(1024 * 1000 * 1000 * 20, "kib"), "20000000K");
|
||||||
assert_eq!(hrn(1024 * 1024 * 1024 * 20, "gb"), "20G");
|
assert_eq!(hrn(1024 * 1024 * 1000 * 20, "mib"), "20000M");
|
||||||
|
assert_eq!(hrn(1024 * 1024 * 1024 * 20, "gib"), "20G");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn build_draw_data<'a>(disp: &'a DisplayData, size: u32) -> (DrawData<'a>, DisplayNode) {
|
fn build_draw_data(disp: &DisplayData, size: u32) -> (DrawData<'_>, DisplayNode) {
|
||||||
let n = DisplayNode {
|
let n = DisplayNode {
|
||||||
name: PathBuf::from("/short"),
|
name: PathBuf::from("/short"),
|
||||||
size: 2_u64.pow(size),
|
size: 2_u64.pow(size),
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
use serde::Serialize;
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Serialize)]
|
||||||
pub struct DisplayNode {
|
pub struct DisplayNode {
|
||||||
// Note: the order of fields in important here, for PartialEq and PartialOrd
|
// Note: the order of fields in important here, for PartialEq and PartialOrd
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
|
|||||||
+108
-39
@@ -21,8 +21,11 @@ use regex::Error;
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
|
use std::io;
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
use std::sync::atomic::AtomicBool;
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use sysinfo::{System, SystemExt};
|
use sysinfo::{System, SystemExt};
|
||||||
@@ -119,17 +122,49 @@ fn main() {
|
|||||||
let error_listen_for_ctrlc = Arc::new(Mutex::new(errors));
|
let error_listen_for_ctrlc = Arc::new(Mutex::new(errors));
|
||||||
let errors_for_rayon = error_listen_for_ctrlc.clone();
|
let errors_for_rayon = error_listen_for_ctrlc.clone();
|
||||||
let errors_final = error_listen_for_ctrlc.clone();
|
let errors_final = error_listen_for_ctrlc.clone();
|
||||||
|
let is_in_listing = Arc::new(AtomicBool::new(false));
|
||||||
|
let cloned_is_in_listing = Arc::clone(&is_in_listing);
|
||||||
|
|
||||||
ctrlc::set_handler(move || {
|
ctrlc::set_handler(move || {
|
||||||
error_listen_for_ctrlc.lock().unwrap().abort = true;
|
error_listen_for_ctrlc.lock().unwrap().abort = true;
|
||||||
println!("\nAborting");
|
println!("\nAborting");
|
||||||
|
if cloned_is_in_listing.load(Ordering::Relaxed) {
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.expect("Error setting Ctrl-C handler");
|
.expect("Error setting Ctrl-C handler");
|
||||||
|
|
||||||
let target_dirs = match options.get_many::<String>("params") {
|
is_in_listing.store(true, Ordering::Relaxed);
|
||||||
Some(values) => values.map(|v| v.as_str()).collect::<Vec<&str>>(),
|
let target_dirs = match config.get_files_from(&options) {
|
||||||
None => vec!["."],
|
Some(path) => {
|
||||||
|
if path == "-" {
|
||||||
|
let mut targets_to_add = io::stdin()
|
||||||
|
.lines()
|
||||||
|
.map_while(Result::ok)
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
|
if targets_to_add.is_empty() {
|
||||||
|
eprintln!("No input provided, defaulting to current directory");
|
||||||
|
targets_to_add.push(".".to_owned());
|
||||||
|
}
|
||||||
|
targets_to_add
|
||||||
|
} else {
|
||||||
|
// read file
|
||||||
|
match read_to_string(path) {
|
||||||
|
Ok(file_content) => file_content.lines().map(|x| x.to_string()).collect(),
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Error reading file: {e}");
|
||||||
|
vec![".".to_owned()]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => match options.get_many::<String>("params") {
|
||||||
|
Some(values) => values.cloned().collect(),
|
||||||
|
None => vec![".".to_owned()],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
is_in_listing.store(false, Ordering::Relaxed);
|
||||||
|
|
||||||
let summarize_file_types = options.get_flag("types");
|
let summarize_file_types = options.get_flag("types");
|
||||||
|
|
||||||
@@ -192,10 +227,10 @@ fn main() {
|
|||||||
let limit_filesystem = options.get_flag("limit_filesystem");
|
let limit_filesystem = options.get_flag("limit_filesystem");
|
||||||
let follow_links = options.get_flag("dereference_links");
|
let follow_links = options.get_flag("dereference_links");
|
||||||
|
|
||||||
let simplified_dirs = simplify_dir_names(target_dirs);
|
|
||||||
let allowed_filesystems = limit_filesystem
|
let allowed_filesystems = limit_filesystem
|
||||||
.then(|| get_filesystem_devices(simplified_dirs.iter()))
|
.then(|| get_filesystem_devices(&target_dirs))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
let simplified_dirs = simplify_dir_names(&target_dirs);
|
||||||
|
|
||||||
let ignored_full_path: HashSet<PathBuf> = ignore_directories
|
let ignored_full_path: HashSet<PathBuf> = ignore_directories
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -211,11 +246,18 @@ fn main() {
|
|||||||
indicator.spawn(output_format.clone())
|
indicator.spawn(output_format.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let filter_modified_time = config.get_modified_time_operator(&options);
|
||||||
|
let filter_accessed_time = config.get_accessed_time_operator(&options);
|
||||||
|
let filter_changed_time = config.get_created_time_operator(&options);
|
||||||
|
|
||||||
let walk_data = WalkData {
|
let walk_data = WalkData {
|
||||||
ignore_directories: ignored_full_path,
|
ignore_directories: ignored_full_path,
|
||||||
filter_regex: &filter_regexs,
|
filter_regex: &filter_regexs,
|
||||||
invert_filter_regex: &invert_filter_regexs,
|
invert_filter_regex: &invert_filter_regexs,
|
||||||
allowed_filesystems,
|
allowed_filesystems,
|
||||||
|
filter_modified_time,
|
||||||
|
filter_accessed_time,
|
||||||
|
filter_changed_time,
|
||||||
use_apparent_size: config.get_apparent_size(&options),
|
use_apparent_size: config.get_apparent_size(&options),
|
||||||
by_filecount,
|
by_filecount,
|
||||||
ignore_hidden,
|
ignore_hidden,
|
||||||
@@ -223,8 +265,9 @@ fn main() {
|
|||||||
progress_data: indicator.data.clone(),
|
progress_data: indicator.data.clone(),
|
||||||
errors: errors_for_rayon,
|
errors: errors_for_rayon,
|
||||||
};
|
};
|
||||||
|
let threads_to_use = config.get_threads(&options);
|
||||||
let stack_size = config.get_custom_stack_size(&options);
|
let stack_size = config.get_custom_stack_size(&options);
|
||||||
init_rayon(&stack_size);
|
init_rayon(&stack_size, &threads_to_use);
|
||||||
|
|
||||||
let top_level_nodes = walk_it(simplified_dirs, &walk_data);
|
let top_level_nodes = walk_it(simplified_dirs, &walk_data);
|
||||||
|
|
||||||
@@ -251,7 +294,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let final_errors = walk_data.errors.lock().unwrap();
|
let final_errors = walk_data.errors.lock().unwrap();
|
||||||
let failed_permissions = final_errors.no_permissions;
|
|
||||||
if !final_errors.file_not_found.is_empty() {
|
if !final_errors.file_not_found.is_empty() {
|
||||||
let err = final_errors
|
let err = final_errors
|
||||||
.file_not_found
|
.file_not_found
|
||||||
@@ -261,8 +303,20 @@ fn main() {
|
|||||||
.join(", ");
|
.join(", ");
|
||||||
eprintln!("No such file or directory: {}", err);
|
eprintln!("No such file or directory: {}", err);
|
||||||
}
|
}
|
||||||
if failed_permissions {
|
if !final_errors.no_permissions.is_empty() {
|
||||||
eprintln!("Did not have permissions for all directories");
|
if config.get_print_errors(&options) {
|
||||||
|
let err = final_errors
|
||||||
|
.no_permissions
|
||||||
|
.iter()
|
||||||
|
.map(|a| a.as_ref())
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.join(", ");
|
||||||
|
eprintln!("Did not have permissions for directories: {}", err);
|
||||||
|
} else {
|
||||||
|
eprintln!(
|
||||||
|
"Did not have permissions for all directories (add --print-errors to see errors)"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !final_errors.unknown_error.is_empty() {
|
if !final_errors.unknown_error.is_empty() {
|
||||||
let err = final_errors
|
let err = final_errors
|
||||||
@@ -284,44 +338,59 @@ fn main() {
|
|||||||
output_format,
|
output_format,
|
||||||
bars_on_right: config.get_bars_on_right(&options),
|
bars_on_right: config.get_bars_on_right(&options),
|
||||||
};
|
};
|
||||||
draw_it(
|
|
||||||
idd,
|
if config.get_output_json(&options) {
|
||||||
config.get_no_bars(&options),
|
println!("{}", serde_json::to_string(&root_node).unwrap());
|
||||||
terminal_width,
|
} else {
|
||||||
&root_node,
|
draw_it(
|
||||||
config.get_skip_total(&options),
|
idd,
|
||||||
)
|
config.get_no_bars(&options),
|
||||||
|
terminal_width,
|
||||||
|
&root_node,
|
||||||
|
config.get_skip_total(&options),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_rayon(stack_size: &Option<usize>) {
|
fn init_rayon(stack_size: &Option<usize>, threads: &Option<usize>) {
|
||||||
// Rayon seems to raise this error on 32-bit builds
|
// Rayon seems to raise this error on 32-bit builds
|
||||||
// The global thread pool has not been initialized.: ThreadPoolBuildError { kind: GlobalPoolAlreadyInitialized }
|
// The global thread pool has not been initialized.: ThreadPoolBuildError { kind: GlobalPoolAlreadyInitialized }
|
||||||
if cfg!(target_pointer_width = "64") {
|
if cfg!(target_pointer_width = "64") {
|
||||||
let result = panic::catch_unwind(|| {
|
let result = panic::catch_unwind(|| build_thread_pool(*stack_size, *threads));
|
||||||
match stack_size {
|
|
||||||
Some(n) => rayon::ThreadPoolBuilder::new()
|
|
||||||
.stack_size(*n)
|
|
||||||
.build_global(),
|
|
||||||
None => {
|
|
||||||
let large_stack = usize::pow(1024, 3);
|
|
||||||
let mut s = System::new();
|
|
||||||
s.refresh_memory();
|
|
||||||
let available = s.available_memory();
|
|
||||||
|
|
||||||
if available > large_stack.try_into().unwrap() {
|
|
||||||
// Larger stack size to handle cases with lots of nested directories
|
|
||||||
rayon::ThreadPoolBuilder::new()
|
|
||||||
.stack_size(large_stack)
|
|
||||||
.build_global()
|
|
||||||
} else {
|
|
||||||
rayon::ThreadPoolBuilder::new().build_global()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
eprintln!("Problem initializing rayon, try: export RAYON_NUM_THREADS=1")
|
eprintln!("Problem initializing rayon, try: export RAYON_NUM_THREADS=1")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn build_thread_pool(
|
||||||
|
stack: Option<usize>,
|
||||||
|
threads: Option<usize>,
|
||||||
|
) -> Result<(), rayon::ThreadPoolBuildError> {
|
||||||
|
let mut pool = rayon::ThreadPoolBuilder::new();
|
||||||
|
|
||||||
|
if let Some(thread_count) = threads {
|
||||||
|
pool = pool.num_threads(thread_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
let stack_size = match stack {
|
||||||
|
Some(s) => Some(s),
|
||||||
|
None => {
|
||||||
|
let large_stack = usize::pow(1024, 3);
|
||||||
|
let mut s = System::new();
|
||||||
|
s.refresh_memory();
|
||||||
|
// Larger stack size if possible to handle cases with lots of nested directories
|
||||||
|
let available = s.available_memory();
|
||||||
|
if available > large_stack.try_into().unwrap() {
|
||||||
|
Some(large_stack)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Some(stack_size_param) = stack_size {
|
||||||
|
pool = pool.stack_size(stack_size_param);
|
||||||
|
}
|
||||||
|
pool.build_global()
|
||||||
|
}
|
||||||
|
|||||||
+17
-8
@@ -1,8 +1,9 @@
|
|||||||
|
use crate::dir_walker::WalkData;
|
||||||
use crate::platform::get_metadata;
|
use crate::platform::get_metadata;
|
||||||
|
use crate::utils::is_filtered_out_due_to_file_time;
|
||||||
use crate::utils::is_filtered_out_due_to_invert_regex;
|
use crate::utils::is_filtered_out_due_to_invert_regex;
|
||||||
use crate::utils::is_filtered_out_due_to_regex;
|
use crate::utils::is_filtered_out_due_to_regex;
|
||||||
|
|
||||||
use regex::Regex;
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
@@ -19,14 +20,14 @@ pub struct Node {
|
|||||||
pub fn build_node(
|
pub fn build_node(
|
||||||
dir: PathBuf,
|
dir: PathBuf,
|
||||||
children: Vec<Node>,
|
children: Vec<Node>,
|
||||||
filter_regex: &[Regex],
|
|
||||||
invert_filter_regex: &[Regex],
|
|
||||||
use_apparent_size: bool,
|
|
||||||
is_symlink: bool,
|
is_symlink: bool,
|
||||||
is_file: bool,
|
is_file: bool,
|
||||||
by_filecount: bool,
|
|
||||||
depth: usize,
|
depth: usize,
|
||||||
|
walk_data: &WalkData,
|
||||||
) -> Option<Node> {
|
) -> Option<Node> {
|
||||||
|
let use_apparent_size = walk_data.use_apparent_size;
|
||||||
|
let by_filecount = walk_data.by_filecount;
|
||||||
|
|
||||||
get_metadata(&dir, use_apparent_size).map(|data| {
|
get_metadata(&dir, use_apparent_size).map(|data| {
|
||||||
let inode_device = if is_symlink && !use_apparent_size {
|
let inode_device = if is_symlink && !use_apparent_size {
|
||||||
None
|
None
|
||||||
@@ -34,11 +35,19 @@ pub fn build_node(
|
|||||||
data.1
|
data.1
|
||||||
};
|
};
|
||||||
|
|
||||||
let size = if is_filtered_out_due_to_regex(filter_regex, &dir)
|
let size = if is_filtered_out_due_to_regex(walk_data.filter_regex, &dir)
|
||||||
|| is_filtered_out_due_to_invert_regex(invert_filter_regex, &dir)
|
|| is_filtered_out_due_to_invert_regex(walk_data.invert_filter_regex, &dir)
|
||||||
|| (is_symlink && !use_apparent_size)
|
|| (is_symlink && !use_apparent_size)
|
||||||
|| by_filecount && !is_file
|
|| by_filecount && !is_file
|
||||||
{
|
|| [
|
||||||
|
(&walk_data.filter_modified_time, data.2 .0),
|
||||||
|
(&walk_data.filter_accessed_time, data.2 .1),
|
||||||
|
(&walk_data.filter_changed_time, data.2 .2),
|
||||||
|
]
|
||||||
|
.iter()
|
||||||
|
.any(|(filter_time, actual_time)| {
|
||||||
|
is_filtered_out_due_to_file_time(filter_time, *actual_time)
|
||||||
|
}) {
|
||||||
0
|
0
|
||||||
} else if by_filecount {
|
} else if by_filecount {
|
||||||
1
|
1
|
||||||
|
|||||||
+50
-14
@@ -10,15 +10,29 @@ fn get_block_size() -> u64 {
|
|||||||
512
|
512
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type InodeAndDevice = (u64, u64);
|
||||||
|
type FileTime = (i64, i64, i64);
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u64, u64)>)> {
|
pub fn get_metadata<P: AsRef<Path>>(
|
||||||
|
path: P,
|
||||||
|
use_apparent_size: bool,
|
||||||
|
) -> Option<(u64, Option<InodeAndDevice>, FileTime)> {
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
match d.metadata() {
|
match path.as_ref().metadata() {
|
||||||
Ok(md) => {
|
Ok(md) => {
|
||||||
if use_apparent_size {
|
if use_apparent_size {
|
||||||
Some((md.len(), Some((md.ino(), md.dev()))))
|
Some((
|
||||||
|
md.len(),
|
||||||
|
Some((md.ino(), md.dev())),
|
||||||
|
(md.mtime(), md.atime(), md.ctime()),
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
Some((md.blocks() * get_block_size(), Some((md.ino(), md.dev()))))
|
Some((
|
||||||
|
md.blocks() * get_block_size(),
|
||||||
|
Some((md.ino(), md.dev())),
|
||||||
|
(md.mtime(), md.atime(), md.ctime()),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_e) => None,
|
Err(_e) => None,
|
||||||
@@ -26,7 +40,10 @@ pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_family = "windows")]
|
#[cfg(target_family = "windows")]
|
||||||
pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u64, u64)>)> {
|
pub fn get_metadata<P: AsRef<Path>>(
|
||||||
|
path: P,
|
||||||
|
use_apparent_size: bool,
|
||||||
|
) -> Option<(u64, Option<InodeAndDevice>, FileTime)> {
|
||||||
// On windows opening the file to get size, file ID and volume can be very
|
// On windows opening the file to get size, file ID and volume can be very
|
||||||
// expensive because 1) it causes a few system calls, and more importantly 2) it can cause
|
// expensive because 1) it causes a few system calls, and more importantly 2) it can cause
|
||||||
// windows defender to scan the file.
|
// windows defender to scan the file.
|
||||||
@@ -65,7 +82,7 @@ pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u
|
|||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use winapi_util::Handle;
|
use winapi_util::Handle;
|
||||||
fn handle_from_path_limited<P: AsRef<Path>>(path: P) -> io::Result<Handle> {
|
fn handle_from_path_limited(path: &Path) -> io::Result<Handle> {
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::os::windows::fs::OpenOptionsExt;
|
use std::os::windows::fs::OpenOptionsExt;
|
||||||
const FILE_READ_ATTRIBUTES: u32 = 0x0080;
|
const FILE_READ_ATTRIBUTES: u32 = 0x0080;
|
||||||
@@ -91,30 +108,41 @@ pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_metadata_expensive(
|
fn get_metadata_expensive(
|
||||||
d: &Path,
|
path: &Path,
|
||||||
use_apparent_size: bool,
|
use_apparent_size: bool,
|
||||||
) -> Option<(u64, Option<(u64, u64)>)> {
|
) -> Option<(u64, Option<InodeAndDevice>, FileTime)> {
|
||||||
use winapi_util::file::information;
|
use winapi_util::file::information;
|
||||||
|
|
||||||
let h = handle_from_path_limited(d).ok()?;
|
let h = handle_from_path_limited(path).ok()?;
|
||||||
let info = information(&h).ok()?;
|
let info = information(&h).ok()?;
|
||||||
|
|
||||||
if use_apparent_size {
|
if use_apparent_size {
|
||||||
use filesize::PathExt;
|
use filesize::PathExt;
|
||||||
Some((
|
Some((
|
||||||
d.size_on_disk().ok()?,
|
path.size_on_disk().ok()?,
|
||||||
Some((info.file_index(), info.volume_serial_number())),
|
Some((info.file_index(), info.volume_serial_number())),
|
||||||
|
(
|
||||||
|
info.last_write_time().unwrap() as i64,
|
||||||
|
info.last_access_time().unwrap() as i64,
|
||||||
|
info.creation_time().unwrap() as i64,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Some((
|
Some((
|
||||||
info.file_size(),
|
info.file_size(),
|
||||||
Some((info.file_index(), info.volume_serial_number())),
|
Some((info.file_index(), info.volume_serial_number())),
|
||||||
|
(
|
||||||
|
info.last_write_time().unwrap() as i64,
|
||||||
|
info.last_access_time().unwrap() as i64,
|
||||||
|
info.creation_time().unwrap() as i64,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::os::windows::fs::MetadataExt;
|
use std::os::windows::fs::MetadataExt;
|
||||||
match d.metadata() {
|
let path = path.as_ref();
|
||||||
|
match path.metadata() {
|
||||||
Ok(ref md) => {
|
Ok(ref md) => {
|
||||||
const FILE_ATTRIBUTE_ARCHIVE: u32 = 0x20;
|
const FILE_ATTRIBUTE_ARCHIVE: u32 = 0x20;
|
||||||
const FILE_ATTRIBUTE_READONLY: u32 = 0x01;
|
const FILE_ATTRIBUTE_READONLY: u32 = 0x01;
|
||||||
@@ -142,11 +170,19 @@ pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u
|
|||||||
|| md.file_attributes() == FILE_ATTRIBUTE_NORMAL)
|
|| md.file_attributes() == FILE_ATTRIBUTE_NORMAL)
|
||||||
&& !((attr_filtered & IS_PROBABLY_ONEDRIVE != 0) && use_apparent_size)
|
&& !((attr_filtered & IS_PROBABLY_ONEDRIVE != 0) && use_apparent_size)
|
||||||
{
|
{
|
||||||
Some((md.len(), None))
|
Some((
|
||||||
|
md.len(),
|
||||||
|
None,
|
||||||
|
(
|
||||||
|
md.last_write_time() as i64,
|
||||||
|
md.last_access_time() as i64,
|
||||||
|
md.creation_time() as i64,
|
||||||
|
),
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
get_metadata_expensive(d, use_apparent_size)
|
get_metadata_expensive(path, use_apparent_size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => get_metadata_expensive(d, use_apparent_size),
|
_ => get_metadata_expensive(path, use_apparent_size),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ impl PAtomicInfo {
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct RuntimeErrors {
|
pub struct RuntimeErrors {
|
||||||
pub no_permissions: bool,
|
pub no_permissions: HashSet<String>,
|
||||||
pub file_not_found: HashSet<String>,
|
pub file_not_found: HashSet<String>,
|
||||||
pub unknown_error: HashSet<String>,
|
pub unknown_error: HashSet<String>,
|
||||||
pub abort: bool,
|
pub abort: bool,
|
||||||
|
|||||||
+30
-13
@@ -2,13 +2,16 @@ use platform::get_metadata;
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use crate::config::DAY_SECONDS;
|
||||||
|
|
||||||
|
use crate::dir_walker::Operater;
|
||||||
use crate::platform;
|
use crate::platform;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
pub fn simplify_dir_names<P: AsRef<Path>>(filenames: Vec<P>) -> HashSet<PathBuf> {
|
pub fn simplify_dir_names<P: AsRef<Path>>(dirs: &[P]) -> HashSet<PathBuf> {
|
||||||
let mut top_level_names: HashSet<PathBuf> = HashSet::with_capacity(filenames.len());
|
let mut top_level_names: HashSet<PathBuf> = HashSet::with_capacity(dirs.len());
|
||||||
|
|
||||||
for t in filenames {
|
for t in dirs {
|
||||||
let top_level_name = normalize_path(t);
|
let top_level_name = normalize_path(t);
|
||||||
let mut can_add = true;
|
let mut can_add = true;
|
||||||
let mut to_remove: Vec<PathBuf> = Vec::new();
|
let mut to_remove: Vec<PathBuf> = Vec::new();
|
||||||
@@ -31,12 +34,12 @@ pub fn simplify_dir_names<P: AsRef<Path>>(filenames: Vec<P>) -> HashSet<PathBuf>
|
|||||||
top_level_names
|
top_level_names
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_filesystem_devices<'a, P: IntoIterator<Item = &'a PathBuf>>(paths: P) -> HashSet<u64> {
|
pub fn get_filesystem_devices<P: AsRef<Path>>(paths: &[P]) -> HashSet<u64> {
|
||||||
// Gets the device ids for the filesystems which are used by the argument paths
|
// Gets the device ids for the filesystems which are used by the argument paths
|
||||||
paths
|
paths
|
||||||
.into_iter()
|
.iter()
|
||||||
.filter_map(|p| match get_metadata(p, false) {
|
.filter_map(|p| match get_metadata(p, false) {
|
||||||
Some((_size, Some((_id, dev)))) => Some(dev),
|
Some((_size, Some((_id, dev)), _time)) => Some(dev),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
@@ -62,6 +65,20 @@ pub fn is_filtered_out_due_to_regex(filter_regex: &[Regex], dir: &Path) -> bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_filtered_out_due_to_file_time(
|
||||||
|
filter_time: &Option<(Operater, i64)>,
|
||||||
|
actual_time: i64,
|
||||||
|
) -> bool {
|
||||||
|
match filter_time {
|
||||||
|
None => false,
|
||||||
|
Some((Operater::Equal, bound_time)) => {
|
||||||
|
!(actual_time >= *bound_time && actual_time < *bound_time + DAY_SECONDS)
|
||||||
|
}
|
||||||
|
Some((Operater::GreaterThan, bound_time)) => actual_time < *bound_time,
|
||||||
|
Some((Operater::LessThan, bound_time)) => actual_time > *bound_time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_filtered_out_due_to_invert_regex(filter_regex: &[Regex], dir: &Path) -> bool {
|
pub fn is_filtered_out_due_to_invert_regex(filter_regex: &[Regex], dir: &Path) -> bool {
|
||||||
filter_regex
|
filter_regex
|
||||||
.iter()
|
.iter()
|
||||||
@@ -82,15 +99,15 @@ mod tests {
|
|||||||
fn test_simplify_dir() {
|
fn test_simplify_dir() {
|
||||||
let mut correct = HashSet::new();
|
let mut correct = HashSet::new();
|
||||||
correct.insert(PathBuf::from("a"));
|
correct.insert(PathBuf::from("a"));
|
||||||
assert_eq!(simplify_dir_names(vec!["a"]), correct);
|
assert_eq!(simplify_dir_names(&["a"]), correct);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_simplify_dir_rm_subdir() {
|
fn test_simplify_dir_rm_subdir() {
|
||||||
let mut correct = HashSet::new();
|
let mut correct = HashSet::new();
|
||||||
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
||||||
assert_eq!(simplify_dir_names(vec!["a/b/c", "a/b", "a/b/d/f"]), correct);
|
assert_eq!(simplify_dir_names(&["a/b/c", "a/b", "a/b/d/f"]), correct);
|
||||||
assert_eq!(simplify_dir_names(vec!["a/b", "a/b/c", "a/b/d/f"]), correct);
|
assert_eq!(simplify_dir_names(&["a/b", "a/b/c", "a/b/d/f"]), correct);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -99,7 +116,7 @@ mod tests {
|
|||||||
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
||||||
correct.insert(PathBuf::from("c"));
|
correct.insert(PathBuf::from("c"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
simplify_dir_names(vec![
|
simplify_dir_names(&[
|
||||||
"a/b",
|
"a/b",
|
||||||
"a/b//",
|
"a/b//",
|
||||||
"a/././b///",
|
"a/././b///",
|
||||||
@@ -118,14 +135,14 @@ mod tests {
|
|||||||
correct.insert(PathBuf::from("b"));
|
correct.insert(PathBuf::from("b"));
|
||||||
correct.insert(["c", "a", "b"].iter().collect::<PathBuf>());
|
correct.insert(["c", "a", "b"].iter().collect::<PathBuf>());
|
||||||
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
||||||
assert_eq!(simplify_dir_names(vec!["a/b", "c/a/b/", "b"]), correct);
|
assert_eq!(simplify_dir_names(&["a/b", "c/a/b/", "b"]), correct);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_simplify_dir_dots() {
|
fn test_simplify_dir_dots() {
|
||||||
let mut correct = HashSet::new();
|
let mut correct = HashSet::new();
|
||||||
correct.insert(PathBuf::from("src"));
|
correct.insert(PathBuf::from("src"));
|
||||||
assert_eq!(simplify_dir_names(vec!["src/."]), correct);
|
assert_eq!(simplify_dir_names(&["src/."]), correct);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -133,7 +150,7 @@ mod tests {
|
|||||||
let mut correct = HashSet::new();
|
let mut correct = HashSet::new();
|
||||||
correct.insert(PathBuf::from("src"));
|
correct.insert(PathBuf::from("src"));
|
||||||
correct.insert(PathBuf::from("src_v2"));
|
correct.insert(PathBuf::from("src_v2"));
|
||||||
assert_eq!(simplify_dir_names(vec!["src/", "src_v2"]), correct);
|
assert_eq!(simplify_dir_names(&["src/", "src_v2"]), correct);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
+72
-23
@@ -1,9 +1,11 @@
|
|||||||
use assert_cmd::Command;
|
use assert_cmd::Command;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::str;
|
use std::process::Output;
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
|
use std::{fs, io, str};
|
||||||
|
|
||||||
static INIT: Once = Once::new();
|
static INIT: Once = Once::new();
|
||||||
|
static UNREADABLE_DIR_PATH: &str = "/tmp/unreadable_dir";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file contains tests that verify the exact output of the command.
|
* This file contains tests that verify the exact output of the command.
|
||||||
@@ -33,34 +35,58 @@ fn copy_test_data(dir: &str) {
|
|||||||
.map_err(|err| eprintln!("Error copying directory for test setup\n{:?}", err));
|
.map_err(|err| eprintln!("Error copying directory for test setup\n{:?}", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn create_unreadable_directory() -> io::Result<()> {
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
use std::fs::Permissions;
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
fs::create_dir_all(UNREADABLE_DIR_PATH)?;
|
||||||
|
fs::set_permissions(UNREADABLE_DIR_PATH, Permissions::from_mode(0))?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn initialize() {
|
fn initialize() {
|
||||||
INIT.call_once(|| {
|
INIT.call_once(|| {
|
||||||
copy_test_data("tests/test_dir");
|
copy_test_data("tests/test_dir");
|
||||||
copy_test_data("tests/test_dir2");
|
copy_test_data("tests/test_dir2");
|
||||||
copy_test_data("tests/test_dir_unicode");
|
copy_test_data("tests/test_dir_unicode");
|
||||||
|
|
||||||
|
if let Err(e) = create_unreadable_directory() {
|
||||||
|
panic!("Failed to create unreadable directory: {}", e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exact_output_test<T: AsRef<OsStr>>(valid_outputs: Vec<String>, command_args: Vec<T>) {
|
fn run_cmd<T: AsRef<OsStr>>(command_args: &[T]) -> Output {
|
||||||
initialize();
|
initialize();
|
||||||
|
let mut to_run = &mut Command::cargo_bin("dust").unwrap();
|
||||||
let mut a = &mut Command::cargo_bin("dust").unwrap();
|
|
||||||
|
|
||||||
for p in command_args {
|
for p in command_args {
|
||||||
a = a.arg(p);
|
to_run = to_run.arg(p);
|
||||||
}
|
}
|
||||||
|
to_run.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
let output = str::from_utf8(&a.unwrap().stdout).unwrap().to_owned();
|
fn exact_stdout_test<T: AsRef<OsStr>>(command_args: &[T], valid_stdout: Vec<String>) {
|
||||||
|
let to_run = run_cmd(command_args);
|
||||||
|
|
||||||
let will_fail = valid_outputs.iter().any(|i| output.contains(i));
|
let stdout_output = str::from_utf8(&to_run.stdout).unwrap().to_owned();
|
||||||
|
let will_fail = valid_stdout.iter().any(|i| stdout_output.contains(i));
|
||||||
if !will_fail {
|
if !will_fail {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"output:\n{}\ndoes not contain any of:\n{}",
|
"output(stdout):\n{}\ndoes not contain any of:\n{}",
|
||||||
output,
|
stdout_output,
|
||||||
valid_outputs.join("\n\n")
|
valid_stdout.join("\n\n")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
assert!(will_fail)
|
assert!(will_fail);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn exact_stderr_test<T: AsRef<OsStr>>(command_args: &[T], valid_stderr: String) {
|
||||||
|
let to_run = run_cmd(command_args);
|
||||||
|
|
||||||
|
let stderr_output = str::from_utf8(&to_run.stderr).unwrap().trim();
|
||||||
|
assert_eq!(stderr_output, valid_stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// "windows" result data can vary by host (size seems to be variable by one byte); fix code vs test and re-enable
|
// "windows" result data can vary by host (size seems to be variable by one byte); fix code vs test and re-enable
|
||||||
@@ -68,20 +94,20 @@ fn exact_output_test<T: AsRef<OsStr>>(valid_outputs: Vec<String>, command_args:
|
|||||||
#[test]
|
#[test]
|
||||||
pub fn test_main_basic() {
|
pub fn test_main_basic() {
|
||||||
// -c is no color mode - This makes testing much simpler
|
// -c is no color mode - This makes testing much simpler
|
||||||
exact_output_test(main_output(), vec!["-c", "-B", "/tmp/test_dir/"])
|
exact_stdout_test(&["-c", "-B", "/tmp/test_dir/"], main_output());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_main_multi_arg() {
|
pub fn test_main_multi_arg() {
|
||||||
let command_args = vec![
|
let command_args = [
|
||||||
"-c",
|
"-c",
|
||||||
"-B",
|
"-B",
|
||||||
"/tmp/test_dir/many/",
|
"/tmp/test_dir/many/",
|
||||||
"/tmp/test_dir",
|
"/tmp/test_dir",
|
||||||
"/tmp/test_dir",
|
"/tmp/test_dir",
|
||||||
];
|
];
|
||||||
exact_output_test(main_output(), command_args);
|
exact_stdout_test(&command_args, main_output());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main_output() -> Vec<String> {
|
fn main_output() -> Vec<String> {
|
||||||
@@ -111,8 +137,8 @@ fn main_output() -> Vec<String> {
|
|||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_main_long_paths() {
|
pub fn test_main_long_paths() {
|
||||||
let command_args = vec!["-c", "-p", "-B", "/tmp/test_dir/"];
|
let command_args = ["-c", "-p", "-B", "/tmp/test_dir/"];
|
||||||
exact_output_test(main_output_long_paths(), command_args);
|
exact_stdout_test(&command_args, main_output_long_paths());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main_output_long_paths() -> Vec<String> {
|
fn main_output_long_paths() -> Vec<String> {
|
||||||
@@ -139,8 +165,8 @@ fn main_output_long_paths() -> Vec<String> {
|
|||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_substring_of_names_and_long_names() {
|
pub fn test_substring_of_names_and_long_names() {
|
||||||
let command_args = vec!["-c", "-B", "/tmp/test_dir2"];
|
let command_args = ["-c", "-B", "/tmp/test_dir2"];
|
||||||
exact_output_test(no_substring_of_names_output(), command_args);
|
exact_stdout_test(&command_args, no_substring_of_names_output());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn no_substring_of_names_output() -> Vec<String> {
|
fn no_substring_of_names_output() -> Vec<String> {
|
||||||
@@ -173,8 +199,8 @@ fn no_substring_of_names_output() -> Vec<String> {
|
|||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_unicode_directories() {
|
pub fn test_unicode_directories() {
|
||||||
let command_args = vec!["-c", "-B", "/tmp/test_dir_unicode"];
|
let command_args = ["-c", "-B", "/tmp/test_dir_unicode"];
|
||||||
exact_output_test(unicode_dir(), command_args);
|
exact_stdout_test(&command_args, unicode_dir());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unicode_dir() -> Vec<String> {
|
fn unicode_dir() -> Vec<String> {
|
||||||
@@ -200,8 +226,8 @@ fn unicode_dir() -> Vec<String> {
|
|||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_apparent_size() {
|
pub fn test_apparent_size() {
|
||||||
let command_args = vec!["-c", "-s", "-b", "/tmp/test_dir"];
|
let command_args = ["-c", "-s", "-b", "/tmp/test_dir"];
|
||||||
exact_output_test(apparent_size_output(), command_args);
|
exact_stdout_test(&command_args, apparent_size_output());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apparent_size_output() -> Vec<String> {
|
fn apparent_size_output() -> Vec<String> {
|
||||||
@@ -222,3 +248,26 @@ fn apparent_size_output() -> Vec<String> {
|
|||||||
|
|
||||||
vec![one_space_before, two_space_before]
|
vec![one_space_before, two_space_before]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
|
#[test]
|
||||||
|
pub fn test_permission_normal() {
|
||||||
|
let command_args = [UNREADABLE_DIR_PATH];
|
||||||
|
let permission_msg =
|
||||||
|
r#"Did not have permissions for all directories (add --print-errors to see errors)"#
|
||||||
|
.trim()
|
||||||
|
.to_string();
|
||||||
|
exact_stderr_test(&command_args, permission_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
|
#[test]
|
||||||
|
pub fn test_permission_flag() {
|
||||||
|
// add the flag to CLI
|
||||||
|
let command_args = ["--print-errors", UNREADABLE_DIR_PATH];
|
||||||
|
let permission_msg = format!(
|
||||||
|
"Did not have permissions for directories: {}",
|
||||||
|
UNREADABLE_DIR_PATH
|
||||||
|
);
|
||||||
|
exact_stderr_test(&command_args, permission_msg);
|
||||||
|
}
|
||||||
|
|||||||
+9
-3
@@ -59,6 +59,12 @@ pub fn test_d_flag_works() {
|
|||||||
assert!(!output.contains("hello_file"));
|
assert!(!output.contains("hello_file"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
pub fn test_threads_flag_works() {
|
||||||
|
let output = build_command(vec!["-T", "1", "tests/test_dir/"]);
|
||||||
|
assert!(output.contains("hello_file"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_d_flag_works_and_still_recurses_down() {
|
pub fn test_d_flag_works_and_still_recurses_down() {
|
||||||
// We had a bug where running with '-d 1' would stop at the first directory and the code
|
// We had a bug where running with '-d 1' would stop at the first directory and the code
|
||||||
@@ -133,9 +139,9 @@ pub fn test_show_files_by_type() {
|
|||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
pub fn test_show_files_only() {
|
pub fn test_show_files_only() {
|
||||||
let output = build_command(vec!["-c", "-F", "tests/test_dir"]);
|
let output = build_command(vec!["-c", "-F", "tests/test_dir"]);
|
||||||
assert!(output.contains("tests/test_dir/many/a_file"));
|
assert!(output.contains("a_file"));
|
||||||
assert!(output.contains("tests/test_dir/many/hello_file"));
|
assert!(output.contains("hello_file"));
|
||||||
assert!(!output.contains("tests/test_dir/many "));
|
assert!(!output.contains("many"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user