mirror of
https://github.com/bootandy/dust.git
synced 2025-12-06 12:51:10 -08:00
Compare commits
66 Commits
kilos2
...
skip_total
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73936a6d0c | ||
|
|
9ba0b6d1d0 | ||
|
|
775d841840 | ||
|
|
609fc1e760 | ||
|
|
eeb686562d | ||
|
|
e0eaeccc0b | ||
|
|
2e56a261e0 | ||
|
|
bfe7323b20 | ||
|
|
1372815007 | ||
|
|
7c9e2f1833 | ||
|
|
1d40ca0870 | ||
|
|
86b2bd944c | ||
|
|
b63608604a | ||
|
|
b24fab720d | ||
|
|
d81b9065a1 | ||
|
|
38c4d23732 | ||
|
|
99bf0fc041 | ||
|
|
75d0566949 | ||
|
|
489d9ada44 | ||
|
|
f48fcc790a | ||
|
|
733117d0f6 | ||
|
|
dbd18f90e7 | ||
|
|
dad88ad660 | ||
|
|
00a7c410a0 | ||
|
|
1ab0b2f531 | ||
|
|
c09073151d | ||
|
|
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 | ||
|
|
25c016f98a | ||
|
|
69c4c63357 | ||
|
|
fbd34ec4c2 | ||
|
|
7c75c1b0a9 | ||
|
|
b54a215805 | ||
|
|
0364cf781e | ||
|
|
a8bf76cb22 | ||
|
|
4df4eeaa38 | ||
|
|
ebb3b8cceb | ||
|
|
e9bacdf875 |
5
.github/workflows/CICD.yml
vendored
5
.github/workflows/CICD.yml
vendored
@@ -45,6 +45,11 @@ jobs:
|
||||
override: true
|
||||
profile: minimal # minimal component installation (ie, no documentation)
|
||||
components: rustfmt, clippy
|
||||
- name: Install wget for Windows
|
||||
if: matrix.job.os == 'windows-latest'
|
||||
run: choco install wget --no-progress
|
||||
- name: typos-action
|
||||
uses: crate-ci/typos@v1.28.4
|
||||
- name: "`fmt` testing"
|
||||
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
|
||||
uses: actions-rs/cargo@v1
|
||||
|
||||
11
.pre-commit-config.yaml
Normal file
11
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
repos:
|
||||
- repo: https://github.com/doublify/pre-commit-rust
|
||||
rev: v1.0
|
||||
hooks:
|
||||
- id: cargo-check
|
||||
stages: [commit]
|
||||
- id: fmt
|
||||
stages: [commit]
|
||||
- id: clippy
|
||||
args: [--all-targets, --all-features]
|
||||
stages: [commit]
|
||||
512
Cargo.lock
generated
512
Cargo.lock
generated
@@ -4,13 +4,28 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"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]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
@@ -22,47 +37,48 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.12"
|
||||
version = "0.6.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540"
|
||||
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.6"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
|
||||
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.3"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
|
||||
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.0.2"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
|
||||
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.2"
|
||||
version = "3.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
|
||||
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys 0.52.0",
|
||||
@@ -70,19 +86,26 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "assert_cmd"
|
||||
version = "2.0.14"
|
||||
version = "2.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed72493ac66d5804837f480ab3766c72bdfab91a65e565fc54fa9e42db0073a8"
|
||||
checksum = "dc1835b7f27878de8525dc71410b5a31cdcc5f230aed5ba5df968e09c201b23d"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"bstr",
|
||||
"doc-comment",
|
||||
"libc",
|
||||
"predicates",
|
||||
"predicates-core",
|
||||
"predicates-tree",
|
||||
"wait-timeout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
@@ -91,21 +114,33 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.2"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "1.9.0"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc"
|
||||
checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"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.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
@@ -113,19 +148,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.1"
|
||||
name = "cfg_aliases"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da"
|
||||
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.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c937d4061031a6d0c8da4b9a4f98a172fc2976dfb1c19213a9cf7d0d3c837e36"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.1"
|
||||
version = "4.5.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb"
|
||||
checksum = "85379ba512b21a328adf887e85f7742d12e96eb31f3ef077df4ffc26b506ffed"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -135,24 +190,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.5.1"
|
||||
version = "4.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c"
|
||||
checksum = "aa3c596da3cf0983427b0df0dba359df9182c13bd5b519b585a482b0c351f4e8"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.0"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
|
||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
||||
|
||||
[[package]]
|
||||
name = "clap_mangen"
|
||||
version = "0.2.20"
|
||||
version = "0.2.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1dd95b5ebb5c1c54581dd6346f3ed6a79a3eef95dd372fc2ac13d535535300e"
|
||||
checksum = "f17415fd4dfbea46e3274fcd8d368284519b358654772afb700dc2e8d2b24eeb"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"roff",
|
||||
@@ -160,9 +215,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.0"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
||||
|
||||
[[package]]
|
||||
name = "config-file"
|
||||
@@ -202,9 +257,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.19"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
|
||||
[[package]]
|
||||
name = "ctrlc"
|
||||
version = "3.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345"
|
||||
dependencies = [
|
||||
"nix",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "difflib"
|
||||
@@ -240,20 +305,24 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
||||
|
||||
[[package]]
|
||||
name = "du-dust"
|
||||
version = "0.9.0"
|
||||
version = "1.1.1"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"assert_cmd",
|
||||
"chrono",
|
||||
"clap",
|
||||
"clap_complete",
|
||||
"clap_mangen",
|
||||
"config-file",
|
||||
"ctrlc",
|
||||
"directories",
|
||||
"filesize",
|
||||
"lscolors",
|
||||
"portable-atomic",
|
||||
"rayon",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"stfu8",
|
||||
"sysinfo",
|
||||
"tempfile",
|
||||
@@ -265,15 +334,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.10.0"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.8"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
|
||||
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
@@ -281,9 +350,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.0.1"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
||||
checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
|
||||
|
||||
[[package]]
|
||||
name = "filesize"
|
||||
@@ -296,9 +365,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.12"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
|
||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@@ -307,9 +376,32 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.6"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd"
|
||||
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]]
|
||||
name = "io-lifetimes"
|
||||
@@ -323,20 +415,40 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.153"
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "libredox"
|
||||
version = "0.0.1"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"
|
||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"bitflags 2.6.0",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -347,9 +459,15 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.13"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "lscolors"
|
||||
@@ -363,9 +481,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.1"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ntapi"
|
||||
@@ -386,6 +516,15 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.19.0"
|
||||
@@ -399,10 +538,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "predicates"
|
||||
version = "3.1.0"
|
||||
name = "portable-atomic"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8"
|
||||
checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265"
|
||||
|
||||
[[package]]
|
||||
name = "predicates"
|
||||
version = "3.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"difflib",
|
||||
@@ -411,15 +556,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "predicates-core"
|
||||
version = "1.0.6"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174"
|
||||
checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931"
|
||||
|
||||
[[package]]
|
||||
name = "predicates-tree"
|
||||
version = "1.0.9"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf"
|
||||
checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13"
|
||||
dependencies = [
|
||||
"predicates-core",
|
||||
"termtree",
|
||||
@@ -427,27 +572,27 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.78"
|
||||
version = "1.0.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
|
||||
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.35"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.8.1"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051"
|
||||
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
@@ -463,20 +608,11 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.4"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4"
|
||||
checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libredox",
|
||||
@@ -485,9 +621,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.10.3"
|
||||
version = "1.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
|
||||
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -497,9 +633,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.5"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"
|
||||
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -508,15 +644,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.2"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
||||
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
||||
|
||||
[[package]]
|
||||
name = "roff"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316"
|
||||
checksum = "88f8660c1ff60292143c98d08fc6e2f654d722db50410e3f3797d40baaf9d8f3"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
@@ -534,37 +670,55 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.31"
|
||||
version = "0.38.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
|
||||
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"bitflags 2.6.0",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.4.13",
|
||||
"linux-raw-sys 0.4.14",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.197"
|
||||
name = "ryu"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.205"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.197"
|
||||
version = "1.0.205"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
||||
checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.122"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stfu8"
|
||||
version = "0.2.7"
|
||||
@@ -573,15 +727,15 @@ checksum = "e51f1e89f093f99e7432c491c382b88a6860a5adbe6bf02574bf0a08efff1978"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.0"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.50"
|
||||
version = "2.0.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb"
|
||||
checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -605,14 +759,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.10.0"
|
||||
version = "3.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67"
|
||||
checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"rustix 0.38.31",
|
||||
"windows-sys 0.52.0",
|
||||
"once_cell",
|
||||
"rustix 0.38.34",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -633,18 +788,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.57"
|
||||
version = "1.0.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b"
|
||||
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.57"
|
||||
version = "1.0.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
|
||||
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -674,15 +829,15 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.11"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
||||
checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "wait-timeout"
|
||||
@@ -699,6 +854,60 @@ version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
@@ -717,11 +926,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.6"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -730,6 +939,15 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
@@ -745,7 +963,16 @@ version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.0",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -765,17 +992,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.0"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.52.0",
|
||||
"windows_aarch64_msvc 0.52.0",
|
||||
"windows_i686_gnu 0.52.0",
|
||||
"windows_i686_msvc 0.52.0",
|
||||
"windows_x86_64_gnu 0.52.0",
|
||||
"windows_x86_64_gnullvm 0.52.0",
|
||||
"windows_x86_64_msvc 0.52.0",
|
||||
"windows_aarch64_gnullvm 0.52.6",
|
||||
"windows_aarch64_msvc 0.52.6",
|
||||
"windows_i686_gnu 0.52.6",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc 0.52.6",
|
||||
"windows_x86_64_gnu 0.52.6",
|
||||
"windows_x86_64_gnullvm 0.52.6",
|
||||
"windows_x86_64_msvc 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -786,9 +1014,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.0"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
@@ -798,9 +1026,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.0"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
@@ -810,9 +1038,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.0"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
@@ -822,9 +1056,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.0"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
@@ -834,9 +1068,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.0"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
@@ -846,9 +1080,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.0"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
@@ -858,6 +1092,6 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.0"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
18
Cargo.toml
18
Cargo.toml
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "du-dust"
|
||||
description = "A more intuitive version of du"
|
||||
version = "0.9.0"
|
||||
version = "1.1.1"
|
||||
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
@@ -38,8 +38,14 @@ stfu8 = "0.2"
|
||||
regex = "1"
|
||||
config-file = "0.2"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
directories = "4"
|
||||
sysinfo = "0.27"
|
||||
ctrlc = "3.4"
|
||||
chrono = "0.4"
|
||||
|
||||
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||
portable-atomic = "1.4"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi-util = "0.1"
|
||||
@@ -80,6 +86,16 @@ assets = [
|
||||
"usr/share/doc/du-dust/README",
|
||||
"644",
|
||||
],
|
||||
[
|
||||
"man-page/dust.1",
|
||||
"usr/share/man/man1/dust.1",
|
||||
"644",
|
||||
],
|
||||
[
|
||||
"completions/dust.bash",
|
||||
"usr/share/bash-completion/completions/dust",
|
||||
"644",
|
||||
],
|
||||
]
|
||||
extended-description = """\
|
||||
Dust is meant to give you an instant overview of which directories are using
|
||||
|
||||
25
README.md
25
README.md
@@ -25,16 +25,30 @@ Because I want an easy way to see where my disk is being used.
|
||||
|
||||
#### 🍺 Homebrew (Linux)
|
||||
|
||||
- `brew tap tgotwig/linux-dust && brew install dust`
|
||||
- `brew install dust`
|
||||
|
||||
#### [Snap](https://ubuntu.com/core/services/guide/snaps-intro) Ubuntu and [supported systems](https://snapcraft.io/docs/installing-snapd)
|
||||
|
||||
- `snap install dust`
|
||||
|
||||
Note: `dust` installed through `snap` can only access files stored in the `/home` directory. See daniejstriata/dust-snap#2 for more information.
|
||||
|
||||
#### [Pacstall](https://github.com/pacstall/pacstall) (Debian/Ubuntu)
|
||||
|
||||
- `pacstall -I dust-bin`
|
||||
|
||||
#### Anaconda (conda-forge)
|
||||
|
||||
- `conda install -c conda-forge dust`
|
||||
|
||||
#### [deb-get](https://github.com/wimpysworld/deb-get) (Debian/Ubuntu)
|
||||
|
||||
- `deb-get install du-dust`
|
||||
|
||||
#### [x-cmd](https://www.x-cmd.com/pkg/#VPContent)
|
||||
|
||||
- `x env use dust`
|
||||
|
||||
#### Windows:
|
||||
|
||||
- `scoop install dust`
|
||||
@@ -68,13 +82,14 @@ Usage: dust -d 3 (Shows 3 levels of subdirectories)
|
||||
Usage: dust -D (Show only directories (eg dust -D))
|
||||
Usage: dust -F (Show only files - finds your largest files)
|
||||
Usage: dust -r (reverse order of output)
|
||||
Usage: dust -H (si print sizes in powers of 1000 instead of 1024)
|
||||
Usage: dust -o si/b/kb/kib/mb/mib/gb/gib (si - prints sizes in powers of 1000. Others print size in that format).
|
||||
Usage: dust -X ignore (ignore all files and directories with the name 'ignore')
|
||||
Usage: dust -x (Only show directories on the same filesystem)
|
||||
Usage: dust -b (Do not show percentages or draw ASCII bars)
|
||||
Usage: dust -B (--bars-on-right - Percent bars moved to right side of screen])
|
||||
Usage: dust -B (--bars-on-right - Percent bars moved to right side of screen)
|
||||
Usage: dust -i (Do not show hidden files)
|
||||
Usage: dust -c (No colors [monochrome])
|
||||
Usage: dust -C (Force colors)
|
||||
Usage: dust -f (Count files instead of diskspace)
|
||||
Usage: dust -t (Group by filetype)
|
||||
Usage: dust -z 10M (min-size, Only include files larger than 10M)
|
||||
@@ -85,7 +100,9 @@ Usage: dust -P (Disable the progress indicator)
|
||||
Usage: dust -R (For screen readers. Removes bars/symbols. Adds new column: depth level. (May want to use -p for full path too))
|
||||
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 -z 4000000 (Exclude output files/directories below size 4MB)
|
||||
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
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
# ----------- To do a release ---------
|
||||
# Compare times of runs to check no drastic slow down:
|
||||
# time target/release/dust ~/dev
|
||||
# time dust ~dev
|
||||
|
||||
# edit version in cargo.toml
|
||||
# ----------- Pre release ---------
|
||||
# Compare times of runs to check no drastic slow down:
|
||||
# hyperfine 'target/release/dust /home/andy'
|
||||
# hyperfine 'dust /home/andy'
|
||||
|
||||
# ----------- Release ---------
|
||||
# inc version in cargo.toml
|
||||
# cargo build --release
|
||||
# commit changed files
|
||||
# merge to master in github
|
||||
|
||||
# tag a commit and push (increment version in Cargo.toml first):
|
||||
# git tag v0.4.5
|
||||
# git push origin v0.4.5
|
||||
|
||||
# cargo publish to put it in crates.io
|
||||
|
||||
# To install locally [Do before pushing it]
|
||||
|
||||
# Optional: To install locally
|
||||
#cargo install --path .
|
||||
|
||||
@@ -14,25 +14,39 @@ _dust() {
|
||||
fi
|
||||
|
||||
local context curcontext="$curcontext" state line
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'-d+[Depth to show]: : ' \
|
||||
'--depth=[Depth to show]: : ' \
|
||||
'-n+[Number of lines of output to show. (Default is terminal_height - 10)]: : ' \
|
||||
'--number-of-lines=[Number of lines of output to show. (Default is terminal_height - 10)]: : ' \
|
||||
'*-X+[Exclude any file or directory with this name]: : ' \
|
||||
'*--ignore-directory=[Exclude any file or directory with this name]: : ' \
|
||||
'-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]: : ' \
|
||||
'--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]: : ' \
|
||||
'-z+[Minimum size file to include in output]: : ' \
|
||||
'--min-size=[Minimum size file to include in output]: : ' \
|
||||
'(-e --filter -t --file_types)*-v+[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]: : ' \
|
||||
'(-e --filter -t --file_types)*--invert-filter=[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]: : ' \
|
||||
'(-t --file_types)*-e+[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]: : ' \
|
||||
'(-t --file_types)*--filter=[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]: : ' \
|
||||
'-w+[Specify width of output overriding the auto detection of terminal width]: : ' \
|
||||
'--terminal_width=[Specify width of output overriding the auto detection of terminal 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)]: : ' \
|
||||
'--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)]: : ' \
|
||||
_arguments "${_arguments_options[@]}" : \
|
||||
'-d+[Depth to show]:DEPTH: ' \
|
||||
'--depth=[Depth to show]:DEPTH: ' \
|
||||
'-T+[Number of threads to use]: : ' \
|
||||
'--threads=[Number of threads to use]: : ' \
|
||||
'--config=[Specify a config file to use]:FILE:_files' \
|
||||
'-n+[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER: ' \
|
||||
'--number-of-lines=[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER: ' \
|
||||
'*-X+[Exclude any file or directory with this path]:PATH:_files' \
|
||||
'*--ignore-directory=[Exclude any file or directory with this path]:PATH:_files' \
|
||||
'-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' \
|
||||
'--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' \
|
||||
'-z+[Minimum size file to include in output]:MIN_SIZE: ' \
|
||||
'--min-size=[Minimum size file to include in output]:MIN_SIZE: ' \
|
||||
'(-e --filter -t --file_types)*-v+[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]:REGEX: ' \
|
||||
'(-e --filter -t --file_types)*--invert-filter=[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]:REGEX: ' \
|
||||
'(-t --file_types)*-e+[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]:REGEX: ' \
|
||||
'(-t --file_types)*--filter=[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]:REGEX: ' \
|
||||
'-w+[Specify width of output overriding the auto detection of terminal width]:WIDTH: ' \
|
||||
'--terminal_width=[Specify width of output overriding the auto detection of terminal width]:WIDTH: ' \
|
||||
'-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)' \
|
||||
'--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' \
|
||||
'-m+[Directory '\''size'\'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time]: :(a c m)' \
|
||||
'--filetime=[Directory '\''size'\'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time]: :(a c m)' \
|
||||
'-p[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]' \
|
||||
@@ -45,6 +59,8 @@ _dust() {
|
||||
'--reverse[Print tree upside down (biggest highest)]' \
|
||||
'-c[No colors will be printed (Useful for commands like\: watch)]' \
|
||||
'--no-colors[No colors will be printed (Useful for commands like\: watch)]' \
|
||||
'-C[Force colors print]' \
|
||||
'--force-colors[Force colors print]' \
|
||||
'-b[No percent bars or percentages will be displayed]' \
|
||||
'--no-percent-bars[No percent bars or percentages will be displayed]' \
|
||||
'-B[percent bars moved to right side of screen]' \
|
||||
@@ -58,19 +74,20 @@ _dust() {
|
||||
'--ignore_hidden[Do not display hidden files]' \
|
||||
'(-d --depth -D --only-dir)-t[show only these file types]' \
|
||||
'(-d --depth -D --only-dir)--file_types[show only these file types]' \
|
||||
'-H[print sizes in powers of 1000 (e.g., 1.1G)]' \
|
||||
'--si[print sizes in powers of 1000 (e.g., 1.1G)]' \
|
||||
'-P[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)--only-dir[Only directories will be displayed.]' \
|
||||
'(-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)]' \
|
||||
'-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]' \
|
||||
'--help[Print help]' \
|
||||
'-V[Print version]' \
|
||||
'--version[Print version]' \
|
||||
'*::params:' \
|
||||
'*::params:_files' \
|
||||
&& ret=0
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,13 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
||||
'dust' {
|
||||
[CompletionResult]::new('-d', 'd', [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('--config', 'config', [CompletionResultType]::ParameterName, 'Specify a config file to use')
|
||||
[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('-X', 'X ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this name')
|
||||
[CompletionResult]::new('--ignore-directory', 'ignore-directory', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this name')
|
||||
[CompletionResult]::new('-X', 'X ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
||||
[CompletionResult]::new('--ignore-directory', 'ignore-directory', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
||||
[CompletionResult]::new('-I', 'I ', [CompletionResultType]::ParameterName, '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')
|
||||
[CompletionResult]::new('--ignore-all-in-file', 'ignore-all-in-file', [CompletionResultType]::ParameterName, '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')
|
||||
[CompletionResult]::new('-z', 'z', [CompletionResultType]::ParameterName, 'Minimum size file to include in output')
|
||||
@@ -37,8 +40,19 @@ 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('-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('-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 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('--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('-m', 'm', [CompletionResultType]::ParameterName, 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time')
|
||||
[CompletionResult]::new('--filetime', 'filetime', [CompletionResultType]::ParameterName, 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time')
|
||||
[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('-L', 'L ', [CompletionResultType]::ParameterName, 'dereference sym links - Treat sym links as directories and go into them')
|
||||
@@ -51,6 +65,8 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
||||
[CompletionResult]::new('--reverse', 'reverse', [CompletionResultType]::ParameterName, 'Print tree upside down (biggest highest)')
|
||||
[CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'No colors will be printed (Useful for commands like: watch)')
|
||||
[CompletionResult]::new('--no-colors', 'no-colors', [CompletionResultType]::ParameterName, 'No colors will be printed (Useful for commands like: watch)')
|
||||
[CompletionResult]::new('-C', 'C ', [CompletionResultType]::ParameterName, 'Force colors print')
|
||||
[CompletionResult]::new('--force-colors', 'force-colors', [CompletionResultType]::ParameterName, 'Force colors print')
|
||||
[CompletionResult]::new('-b', 'b', [CompletionResultType]::ParameterName, 'No percent bars or percentages will be displayed')
|
||||
[CompletionResult]::new('--no-percent-bars', 'no-percent-bars', [CompletionResultType]::ParameterName, 'No percent bars or percentages will be displayed')
|
||||
[CompletionResult]::new('-B', 'B ', [CompletionResultType]::ParameterName, 'percent bars moved to right side of screen')
|
||||
@@ -64,14 +80,15 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
||||
[CompletionResult]::new('--ignore_hidden', 'ignore_hidden', [CompletionResultType]::ParameterName, 'Do not display hidden files')
|
||||
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'show only these file types')
|
||||
[CompletionResult]::new('--file_types', 'file_types', [CompletionResultType]::ParameterName, 'show only these file types')
|
||||
[CompletionResult]::new('-H', 'H ', [CompletionResultType]::ParameterName, 'print sizes in powers of 1000 (e.g., 1.1G)')
|
||||
[CompletionResult]::new('--si', 'si', [CompletionResultType]::ParameterName, 'print sizes in powers of 1000 (e.g., 1.1G)')
|
||||
[CompletionResult]::new('-P', 'P ', [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('--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('--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('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||
[CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
|
||||
|
||||
@@ -19,7 +19,7 @@ _dust() {
|
||||
|
||||
case "${cmd}" in
|
||||
dust)
|
||||
opts="-d -n -p -X -I -L -x -s -r -c -b -B -z -R -f -i -v -e -t -w -H -P -D -F -S -h -V --depth --number-of-lines --full-paths --ignore-directory --ignore-all-in-file --dereference-links --limit-filesystem --apparent-size --reverse --no-colors --no-percent-bars --bars-on-right --min-size --screen-reader --skip-total --filecount --ignore_hidden --invert-filter --filter --file_types --terminal_width --si --no-progress --only-dir --only-file --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 -m -h -V --depth --threads --config --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 --filetime --help --version [PATH]..."
|
||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
@@ -33,6 +33,29 @@ _dust() {
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
--threads)
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
-T)
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
--config)
|
||||
local oldifs
|
||||
if [ -n "${IFS+x}" ]; then
|
||||
oldifs="$IFS"
|
||||
fi
|
||||
IFS=$'\n'
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
if [ -n "${oldifs+x}" ]; then
|
||||
IFS="$oldifs"
|
||||
fi
|
||||
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
|
||||
compopt -o filenames
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
--number-of-lines)
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
return 0
|
||||
@@ -50,11 +73,33 @@ _dust() {
|
||||
return 0
|
||||
;;
|
||||
--ignore-all-in-file)
|
||||
local oldifs
|
||||
if [ -n "${IFS+x}" ]; then
|
||||
oldifs="$IFS"
|
||||
fi
|
||||
IFS=$'\n'
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
if [ -n "${oldifs+x}" ]; then
|
||||
IFS="$oldifs"
|
||||
fi
|
||||
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
|
||||
compopt -o filenames
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
-I)
|
||||
local oldifs
|
||||
if [ -n "${IFS+x}" ]; then
|
||||
oldifs="$IFS"
|
||||
fi
|
||||
IFS=$'\n'
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
if [ -n "${oldifs+x}" ]; then
|
||||
IFS="$oldifs"
|
||||
fi
|
||||
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
|
||||
compopt -o filenames
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
--min-size)
|
||||
@@ -89,6 +134,14 @@ _dust() {
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
--output-format)
|
||||
COMPREPLY=($(compgen -W "si b k m g t kb mb gb tb" -- "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
-o)
|
||||
COMPREPLY=($(compgen -W "si b k m g t kb mb gb tb" -- "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
--stack-size)
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
return 0
|
||||
@@ -97,6 +150,42 @@ _dust() {
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
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
|
||||
;;
|
||||
--filetime)
|
||||
COMPREPLY=($(compgen -W "a c m" -- "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
-m)
|
||||
COMPREPLY=($(compgen -W "a c m" -- "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
|
||||
@@ -20,10 +20,13 @@ set edit:completion:arg-completer[dust] = {|@words|
|
||||
&'dust'= {
|
||||
cand -d 'Depth to show'
|
||||
cand --depth 'Depth to show'
|
||||
cand -T 'Number of threads to use'
|
||||
cand --threads 'Number of threads to use'
|
||||
cand --config 'Specify a config file to use'
|
||||
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 -X 'Exclude any file or directory with this name'
|
||||
cand --ignore-directory 'Exclude any file or directory with this name'
|
||||
cand -X 'Exclude any file or directory with this path'
|
||||
cand --ignore-directory 'Exclude any file or directory with this path'
|
||||
cand -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'
|
||||
cand --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'
|
||||
cand -z 'Minimum size file to include in output'
|
||||
@@ -34,8 +37,19 @@ set edit:completion:arg-completer[dust] = {|@words|
|
||||
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 --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 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 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 --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 -m 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time'
|
||||
cand --filetime 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time'
|
||||
cand -p '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'
|
||||
@@ -48,6 +62,8 @@ set edit:completion:arg-completer[dust] = {|@words|
|
||||
cand --reverse 'Print tree upside down (biggest highest)'
|
||||
cand -c 'No colors will be printed (Useful for commands like: watch)'
|
||||
cand --no-colors 'No colors will be printed (Useful for commands like: watch)'
|
||||
cand -C 'Force colors print'
|
||||
cand --force-colors 'Force colors print'
|
||||
cand -b 'No percent bars or percentages will be displayed'
|
||||
cand --no-percent-bars 'No percent bars or percentages will be displayed'
|
||||
cand -B 'percent bars moved to right side of screen'
|
||||
@@ -61,14 +77,15 @@ set edit:completion:arg-completer[dust] = {|@words|
|
||||
cand --ignore_hidden 'Do not display hidden files'
|
||||
cand -t 'show only these file types'
|
||||
cand --file_types 'show only these file types'
|
||||
cand -H 'print sizes in powers of 1000 (e.g., 1.1G)'
|
||||
cand --si 'print sizes in powers of 1000 (e.g., 1.1G)'
|
||||
cand -P '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 --only-dir 'Only directories will be displayed.'
|
||||
cand -F '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 --help 'Print help'
|
||||
cand -V 'Print version'
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
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 -l config -d 'Specify a config file to use' -r -F
|
||||
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 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 X -l ignore-directory -d 'Exclude any file or directory with this path' -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 -F
|
||||
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 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 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\t'',b\t'',k\t'',m\t'',g\t'',t\t'',kb\t'',mb\t'',gb\t'',tb\t''}"
|
||||
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 m -l filetime -d 'Directory \'size\' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time' -r -f -a "{a\t'',c\t'',m\t''}"
|
||||
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 x -l limit-filesystem -d 'Only count the files and directories on the same filesystem as the supplied directory'
|
||||
complete -c dust -s s -l apparent-size -d 'Use file length instead of blocks'
|
||||
complete -c dust -s r -l reverse -d 'Print tree upside down (biggest highest)'
|
||||
complete -c dust -s c -l no-colors -d 'No colors will be printed (Useful for commands like: watch)'
|
||||
complete -c dust -s C -l force-colors -d 'Force colors print'
|
||||
complete -c dust -s b -l no-percent-bars -d 'No percent bars or percentages will be displayed'
|
||||
complete -c dust -s B -l bars-on-right -d 'percent bars moved to right side of screen'
|
||||
complete -c dust -s R -l screen-reader -d 'For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)'
|
||||
@@ -20,9 +29,10 @@ complete -c dust -l skip-total -d 'No total row will be displayed'
|
||||
complete -c dust -s f -l filecount -d 'Directory \'size\' is number of child files instead of disk size'
|
||||
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 H -l si -d 'print sizes in powers of 1000 (e.g., 1.1G)'
|
||||
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 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 V -l version -d 'Print version'
|
||||
|
||||
@@ -25,4 +25,4 @@ skip-total=true
|
||||
ignore-hidden=true
|
||||
|
||||
# print sizes in powers of 1000 (e.g., 1.1G)
|
||||
iso=true
|
||||
output-format="si"
|
||||
@@ -1,27 +1,33 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH Dust 1 "Dust 0.9.0"
|
||||
.TH Dust 1 "Dust 1.1.1"
|
||||
.SH NAME
|
||||
Dust \- Like du but more intuitive
|
||||
.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\-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\-H\fR|\fB\-\-si\fR] [\fB\-P\fR|\fB\-\-no\-progress\fR] [\fB\-D\fR|\fB\-\-only\-dir\fR] [\fB\-F\fR|\fB\-\-only\-file\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\-\-config\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\-m\fR|\fB\-\-filetime\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIPATH\fR]
|
||||
.SH DESCRIPTION
|
||||
Like du but more intuitive
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-depth\fR
|
||||
\fB\-d\fR, \fB\-\-depth\fR=\fIDEPTH\fR
|
||||
Depth to show
|
||||
.TP
|
||||
\fB\-n\fR, \fB\-\-number\-of\-lines\fR
|
||||
\fB\-T\fR, \fB\-\-threads\fR
|
||||
Number of threads to use
|
||||
.TP
|
||||
\fB\-\-config\fR=\fIFILE\fR
|
||||
Specify a config file 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)
|
||||
.TP
|
||||
\fB\-p\fR, \fB\-\-full\-paths\fR
|
||||
Subdirectories will not have their path shortened
|
||||
.TP
|
||||
\fB\-X\fR, \fB\-\-ignore\-directory\fR
|
||||
Exclude any file or directory with this name
|
||||
\fB\-X\fR, \fB\-\-ignore\-directory\fR=\fIPATH\fR
|
||||
Exclude any file or directory with this path
|
||||
.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
|
||||
.TP
|
||||
\fB\-L\fR, \fB\-\-dereference\-links\fR
|
||||
@@ -39,13 +45,16 @@ Print tree upside down (biggest highest)
|
||||
\fB\-c\fR, \fB\-\-no\-colors\fR
|
||||
No colors will be printed (Useful for commands like: watch)
|
||||
.TP
|
||||
\fB\-C\fR, \fB\-\-force\-colors\fR
|
||||
Force colors print
|
||||
.TP
|
||||
\fB\-b\fR, \fB\-\-no\-percent\-bars\fR
|
||||
No percent bars or percentages will be displayed
|
||||
.TP
|
||||
\fB\-B\fR, \fB\-\-bars\-on\-right\fR
|
||||
percent bars moved to right side of screen
|
||||
.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
|
||||
.TP
|
||||
\fB\-R\fR, \fB\-\-screen\-reader\fR
|
||||
@@ -60,40 +69,69 @@ Directory \*(Aqsize\*(Aq is number of child files instead of disk size
|
||||
\fB\-i\fR, \fB\-\-ignore_hidden\fR
|
||||
Do not display hidden files
|
||||
.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$"
|
||||
.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$"
|
||||
.TP
|
||||
\fB\-t\fR, \fB\-\-file_types\fR
|
||||
show only these file types
|
||||
.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
|
||||
.TP
|
||||
\fB\-H\fR, \fB\-\-si\fR
|
||||
print sizes in powers of 1000 (e.g., 1.1G)
|
||||
.TP
|
||||
\fB\-P\fR, \fB\-\-no\-progress\fR
|
||||
Disable the progress indication.
|
||||
.TP
|
||||
\fB\-\-print\-errors\fR
|
||||
Print path with errors.
|
||||
.TP
|
||||
\fB\-D\fR, \fB\-\-only\-dir\fR
|
||||
Only directories will be displayed.
|
||||
.TP
|
||||
\fB\-F\fR, \fB\-\-only\-file\fR
|
||||
Only files will be displayed. (Finds your largest files)
|
||||
.TP
|
||||
\fB\-S\fR, \fB\-\-stack\-size\fR
|
||||
\fB\-o\fR, \fB\-\-output\-format\fR=\fIFORMAT\fR
|
||||
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
|
||||
\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)
|
||||
.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\-m\fR, \fB\-\-filetime\fR
|
||||
Directory \*(Aqsize\*(Aq is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time
|
||||
.br
|
||||
|
||||
.br
|
||||
[\fIpossible values: \fRa, c, m]
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version
|
||||
.TP
|
||||
[\fIparams\fR]
|
||||
[\fIPATH\fR]
|
||||
|
||||
.SH VERSION
|
||||
v0.9.0
|
||||
v1.1.1
|
||||
|
||||
140
src/cli.rs
140
src/cli.rs
@@ -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:
|
||||
// export RAYON_NUM_THREADS=1
|
||||
@@ -7,19 +7,37 @@ pub fn build_cli() -> Command {
|
||||
Command::new("Dust")
|
||||
.about("Like du but more intuitive")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.trailing_var_arg(true)
|
||||
.arg(
|
||||
Arg::new("depth")
|
||||
.short('d')
|
||||
.long("depth")
|
||||
.value_name("DEPTH")
|
||||
.value_parser(value_parser!(usize))
|
||||
.help("Depth to show")
|
||||
.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::new("config")
|
||||
.long("config")
|
||||
.help("Specify a config file to use")
|
||||
.value_name("FILE")
|
||||
.value_hint(clap::ValueHint::FilePath)
|
||||
.value_parser(value_parser!(String))
|
||||
.num_args(1)
|
||||
)
|
||||
.arg(
|
||||
Arg::new("number_of_lines")
|
||||
.short('n')
|
||||
.long("number-of-lines")
|
||||
.value_name("NUMBER")
|
||||
.value_parser(value_parser!(usize))
|
||||
.help("Number of lines of output to show. (Default is terminal_height - 10)")
|
||||
.num_args(1)
|
||||
@@ -35,13 +53,17 @@ pub fn build_cli() -> Command {
|
||||
Arg::new("ignore_directory")
|
||||
.short('X')
|
||||
.long("ignore-directory")
|
||||
.value_name("PATH")
|
||||
.value_hint(clap::ValueHint::AnyPath)
|
||||
.action(clap::ArgAction::Append)
|
||||
.help("Exclude any file or directory with this name"),
|
||||
.help("Exclude any file or directory with this path"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("ignore_all_in_file")
|
||||
.short('I')
|
||||
.long("ignore-all-in-file")
|
||||
.value_name("FILE")
|
||||
.value_hint(clap::ValueHint::FilePath)
|
||||
.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"),
|
||||
)
|
||||
@@ -80,6 +102,13 @@ pub fn build_cli() -> Command {
|
||||
.action(clap::ArgAction::SetTrue)
|
||||
.help("No colors will be printed (Useful for commands like: watch)"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("force_colors")
|
||||
.short('C')
|
||||
.long("force-colors")
|
||||
.action(clap::ArgAction::SetTrue)
|
||||
.help("Force colors print"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("no_bars")
|
||||
.short('b')
|
||||
@@ -98,6 +127,7 @@ pub fn build_cli() -> Command {
|
||||
Arg::new("min_size")
|
||||
.short('z')
|
||||
.long("min-size")
|
||||
.value_name("MIN_SIZE")
|
||||
.num_args(1)
|
||||
.help("Minimum size file to include in output"),
|
||||
)
|
||||
@@ -132,6 +162,7 @@ pub fn build_cli() -> Command {
|
||||
Arg::new("invert_filter")
|
||||
.short('v')
|
||||
.long("invert-filter")
|
||||
.value_name("REGEX")
|
||||
.action(clap::ArgAction::Append)
|
||||
.conflicts_with("filter")
|
||||
.conflicts_with("types")
|
||||
@@ -141,6 +172,7 @@ pub fn build_cli() -> Command {
|
||||
Arg::new("filter")
|
||||
.short('e')
|
||||
.long("filter")
|
||||
.value_name("REGEX")
|
||||
.action(clap::ArgAction::Append)
|
||||
.conflicts_with("types")
|
||||
.help("Only include filepaths matching this regex. For png files type: -e \"\\.png$\" "),
|
||||
@@ -158,17 +190,11 @@ pub fn build_cli() -> Command {
|
||||
Arg::new("width")
|
||||
.short('w')
|
||||
.long("terminal_width")
|
||||
.num_args(1)
|
||||
.value_name("WIDTH")
|
||||
.value_parser(value_parser!(usize))
|
||||
.num_args(1)
|
||||
.help("Specify width of output overriding the auto detection of terminal width"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("iso")
|
||||
.short('H')
|
||||
.long("si")
|
||||
.action(clap::ArgAction::SetTrue)
|
||||
.help("print sizes in powers of 1000 (e.g., 1.1G)")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("disable_progress")
|
||||
.short('P')
|
||||
@@ -176,6 +202,12 @@ pub fn build_cli() -> Command {
|
||||
.action(clap::ArgAction::SetTrue)
|
||||
.help("Disable the progress indication."),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("print_errors")
|
||||
.long("print-errors")
|
||||
.action(clap::ArgAction::SetTrue)
|
||||
.help("Print path with errors."),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("only_dir")
|
||||
.short('D')
|
||||
@@ -193,14 +225,94 @@ pub fn build_cli() -> Command {
|
||||
.action(clap::ArgAction::SetTrue)
|
||||
.help("Only files will be displayed. (Finds your largest files)"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("output_format")
|
||||
.short('o')
|
||||
.long("output-format")
|
||||
.value_name("FORMAT")
|
||||
.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::new("stack_size")
|
||||
.short('S')
|
||||
.long("stack-size")
|
||||
.num_args(1)
|
||||
.value_name("STACK_SIZE")
|
||||
.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)"),
|
||||
)
|
||||
.arg(Arg::new("params").num_args(1..)
|
||||
.value_parser(value_parser!(String)))
|
||||
.arg(
|
||||
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"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("filetime")
|
||||
.short('m')
|
||||
.long("filetime")
|
||||
.num_args(1)
|
||||
.value_parser([
|
||||
PossibleValue::new("a").alias("accessed"),
|
||||
PossibleValue::new("c").alias("changed"),
|
||||
PossibleValue::new("m").alias("modified"),
|
||||
])
|
||||
.help("Directory 'size' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time"),
|
||||
)
|
||||
}
|
||||
|
||||
300
src/config.rs
300
src/config.rs
@@ -1,25 +1,31 @@
|
||||
use crate::node::FileTime;
|
||||
use chrono::{Local, TimeZone};
|
||||
use clap::ArgMatches;
|
||||
use config_file::FromConfigFile;
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
use std::io::IsTerminal;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::display::UNITS;
|
||||
use crate::dir_walker::Operator;
|
||||
use crate::display::get_number_format;
|
||||
|
||||
pub static DAY_SECONDS: i64 = 24 * 60 * 60;
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Config {
|
||||
pub display_full_paths: Option<bool>,
|
||||
pub display_apparent_size: Option<bool>,
|
||||
pub reverse: Option<bool>,
|
||||
pub no_colors: Option<bool>,
|
||||
pub force_colors: Option<bool>,
|
||||
pub no_bars: Option<bool>,
|
||||
pub skip_total: Option<bool>,
|
||||
pub screen_reader: Option<bool>,
|
||||
pub ignore_hidden: Option<bool>,
|
||||
pub iso: Option<bool>,
|
||||
pub output_format: Option<String>,
|
||||
pub min_size: Option<String>,
|
||||
pub only_dir: Option<bool>,
|
||||
pub only_file: Option<bool>,
|
||||
@@ -27,12 +33,26 @@ pub struct Config {
|
||||
pub depth: Option<usize>,
|
||||
pub bars_on_right: Option<bool>,
|
||||
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 {
|
||||
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 {
|
||||
Some(true) == self.no_colors || options.get_flag("no_colors")
|
||||
}
|
||||
pub fn get_force_colors(&self, options: &ArgMatches) -> bool {
|
||||
Some(true) == self.force_colors || options.get_flag("force_colors")
|
||||
}
|
||||
pub fn get_disable_progress(&self, options: &ArgMatches) -> bool {
|
||||
Some(true) == self.disable_progress
|
||||
|| options.get_flag("disable_progress")
|
||||
@@ -45,10 +65,7 @@ impl Config {
|
||||
Some(true) == self.ignore_hidden || options.get_flag("ignore_hidden")
|
||||
}
|
||||
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")
|
||||
|| self.get_only_file(options)
|
||||
Some(true) == self.display_full_paths || options.get_flag("display_full_paths")
|
||||
}
|
||||
pub fn get_reverse(&self, options: &ArgMatches) -> bool {
|
||||
Some(true) == self.reverse || options.get_flag("reverse")
|
||||
@@ -56,9 +73,31 @@ impl Config {
|
||||
pub fn get_no_bars(&self, options: &ArgMatches) -> bool {
|
||||
Some(true) == self.no_bars || options.get_flag("no_bars")
|
||||
}
|
||||
pub fn get_iso(&self, options: &ArgMatches) -> bool {
|
||||
Some(true) == self.iso || options.get_flag("iso")
|
||||
pub fn get_output_format(&self, options: &ArgMatches) -> String {
|
||||
let out_fmt = options.get_one::<String>("output_format");
|
||||
(match out_fmt {
|
||||
None => match &self.output_format {
|
||||
None => "".to_string(),
|
||||
Some(x) => x.to_string(),
|
||||
},
|
||||
Some(x) => x.into(),
|
||||
})
|
||||
.to_lowercase()
|
||||
}
|
||||
|
||||
pub fn get_filetime(&self, options: &ArgMatches) -> Option<FileTime> {
|
||||
let out_fmt = options.get_one::<String>("filetime");
|
||||
match out_fmt {
|
||||
None => None,
|
||||
Some(x) => match x.as_str() {
|
||||
"m" | "modified" => Some(FileTime::Modified),
|
||||
"a" | "accessed" => Some(FileTime::Accessed),
|
||||
"c" | "changed" => Some(FileTime::Changed),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_skip_total(&self, options: &ArgMatches) -> bool {
|
||||
Some(true) == self.skip_total || options.get_flag("skip_total")
|
||||
}
|
||||
@@ -72,17 +111,17 @@ impl Config {
|
||||
|
||||
self.depth.unwrap_or(usize::MAX)
|
||||
}
|
||||
pub fn get_min_size(&self, options: &ArgMatches, iso: bool) -> Option<usize> {
|
||||
pub fn get_min_size(&self, options: &ArgMatches) -> Option<usize> {
|
||||
let size_from_param = options.get_one::<String>("min_size");
|
||||
self._get_min_size(size_from_param, iso)
|
||||
self._get_min_size(size_from_param)
|
||||
}
|
||||
fn _get_min_size(&self, min_size: Option<&String>, iso: bool) -> Option<usize> {
|
||||
let size_from_param = min_size.and_then(|a| convert_min_size(a, iso));
|
||||
fn _get_min_size(&self, min_size: Option<&String>) -> Option<usize> {
|
||||
let size_from_param = min_size.and_then(|a| convert_min_size(a));
|
||||
|
||||
if size_from_param.is_none() {
|
||||
self.min_size
|
||||
.as_ref()
|
||||
.and_then(|a| convert_min_size(a.as_ref(), iso))
|
||||
.and_then(|a| convert_min_size(a.as_ref()))
|
||||
} else {
|
||||
size_from_param
|
||||
}
|
||||
@@ -90,6 +129,10 @@ impl Config {
|
||||
pub fn get_only_dir(&self, options: &ArgMatches) -> bool {
|
||||
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 {
|
||||
Some(true) == self.only_file || options.get_flag("only_file")
|
||||
}
|
||||
@@ -104,38 +147,102 @@ impl Config {
|
||||
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<(Operator, 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<(Operator, i64)> {
|
||||
get_filter_time_operator(
|
||||
options.get_one::<String>("atime"),
|
||||
get_current_date_epoch_seconds(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_changed_time_operator(&self, options: &ArgMatches) -> Option<(Operator, i64)> {
|
||||
get_filter_time_operator(
|
||||
options.get_one::<String>("ctime"),
|
||||
get_current_date_epoch_seconds(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_min_size(input: &str, iso: bool) -> Option<usize> {
|
||||
let chars_as_vec: Vec<char> = input.chars().collect();
|
||||
match chars_as_vec.split_last() {
|
||||
Some((last, start)) => {
|
||||
let mut starts: String = start.iter().collect::<String>();
|
||||
fn get_current_date_epoch_seconds() -> i64 {
|
||||
// calculate current date epoch seconds
|
||||
let now = Local::now();
|
||||
let current_date = now.date_naive();
|
||||
|
||||
for (i, u) in UNITS.iter().rev().enumerate() {
|
||||
if Some(*u) == last.to_uppercase().next() {
|
||||
return match starts.parse::<usize>() {
|
||||
Ok(pure) => {
|
||||
let num: usize = if iso { 1000 } else { 1024 };
|
||||
let marker = pure * num.pow((i + 1) as u32);
|
||||
Some(marker)
|
||||
}
|
||||
Err(_) => {
|
||||
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<(Operator, 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((Operator::LessThan, time - DAY_SECONDS)),
|
||||
'-' => Some((Operator::GreaterThan, time)),
|
||||
_ => Some((Operator::Equal, time - DAY_SECONDS)),
|
||||
}
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_min_size(input: &str) -> Option<usize> {
|
||||
let re = Regex::new(r"([0-9]+)(\w*)").unwrap();
|
||||
|
||||
if let Some(cap) = re.captures(input) {
|
||||
let (_, [digits, letters]) = cap.extract();
|
||||
|
||||
// Failure to parse should be impossible due to regex match
|
||||
let digits_as_usize: Option<usize> = digits.parse().ok();
|
||||
|
||||
match digits_as_usize {
|
||||
Some(parsed_digits) => {
|
||||
let number_format = get_number_format(&letters.to_lowercase());
|
||||
match number_format {
|
||||
Some((multiple, _)) => Some(parsed_digits * (multiple as usize)),
|
||||
None => {
|
||||
if letters.is_empty() {
|
||||
Some(parsed_digits)
|
||||
} else {
|
||||
eprintln!("Ignoring invalid min-size: {input}");
|
||||
None
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
starts.push(*last);
|
||||
starts
|
||||
.parse()
|
||||
.map_err(|_| {
|
||||
eprintln!("Ignoring invalid min-size: {input}");
|
||||
})
|
||||
.ok()
|
||||
None => None,
|
||||
}
|
||||
None => None,
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,12 +253,29 @@ fn get_config_locations(base: &Path) -> Vec<PathBuf> {
|
||||
]
|
||||
}
|
||||
|
||||
pub fn get_config() -> Config {
|
||||
if let Some(home) = directories::BaseDirs::new() {
|
||||
for path in get_config_locations(home.home_dir()) {
|
||||
pub fn get_config(conf_path: Option<String>) -> Config {
|
||||
match conf_path {
|
||||
Some(path_str) => {
|
||||
let path = Path::new(&path_str);
|
||||
if path.exists() {
|
||||
if let Ok(config) = Config::from_config_file(path) {
|
||||
return config;
|
||||
match Config::from_config_file(path) {
|
||||
Ok(config) => return config,
|
||||
Err(e) => {
|
||||
eprintln!("Ignoring invalid config file '{}': {}", &path.display(), e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eprintln!("Config file {:?} doesn't exists", &path.display());
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if let Some(home) = directories::BaseDirs::new() {
|
||||
for path in get_config_locations(home.home_dir()) {
|
||||
if path.exists() {
|
||||
if let Ok(config) = Config::from_config_file(&path) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,30 +289,46 @@ pub fn get_config() -> Config {
|
||||
mod tests {
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use chrono::{Datelike, Timelike};
|
||||
use clap::builder::PossibleValue;
|
||||
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]
|
||||
fn test_conversion() {
|
||||
assert_eq!(convert_min_size("55", false), Some(55));
|
||||
assert_eq!(convert_min_size("12344321", false), Some(12344321));
|
||||
assert_eq!(convert_min_size("95RUBBISH", false), None);
|
||||
assert_eq!(convert_min_size("10K", false), Some(10 * 1024));
|
||||
assert_eq!(convert_min_size("10M", false), Some(10 * 1024usize.pow(2)));
|
||||
assert_eq!(convert_min_size("10M", true), Some(10 * 1000usize.pow(2)));
|
||||
assert_eq!(convert_min_size("2G", false), Some(2 * 1024usize.pow(3)));
|
||||
assert_eq!(convert_min_size("55"), Some(55));
|
||||
assert_eq!(convert_min_size("12344321"), Some(12344321));
|
||||
assert_eq!(convert_min_size("95RUBBISH"), None);
|
||||
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("10Mb"), Some(10 * 1000usize.pow(2)));
|
||||
assert_eq!(convert_min_size("2Gi"), Some(2 * 1024usize.pow(3)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_min_size_from_config_applied_or_overridden() {
|
||||
let c = Config {
|
||||
min_size: Some("1K".to_owned()),
|
||||
min_size: Some("1KiB".to_owned()),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(c._get_min_size(None, false), Some(1024));
|
||||
assert_eq!(c._get_min_size(Some(&"2K".into()), false), Some(2048));
|
||||
assert_eq!(c._get_min_size(None), Some(1024));
|
||||
assert_eq!(c._get_min_size(Some(&"2KiB".into())), Some(2048));
|
||||
|
||||
assert_eq!(c._get_min_size(None, true), Some(1000));
|
||||
assert_eq!(c._get_min_size(Some(&"2K".into()), true), Some(2000));
|
||||
assert_eq!(c._get_min_size(Some(&"1kb".into())), Some(1000));
|
||||
assert_eq!(c._get_min_size(Some(&"2KB".into())), Some(2000));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -230,4 +370,56 @@ mod tests {
|
||||
)
|
||||
.get_matches_from(args)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_filetime() {
|
||||
// No config and no flag.
|
||||
let c = Config::default();
|
||||
let args = get_filetime_args(vec!["dust"]);
|
||||
assert_eq!(c.get_filetime(&args), None);
|
||||
|
||||
// Config is not defined and flag is defined as access time
|
||||
let c = Config::default();
|
||||
let args = get_filetime_args(vec!["dust", "--filetime", "a"]);
|
||||
assert_eq!(c.get_filetime(&args), Some(FileTime::Accessed));
|
||||
|
||||
let c = Config::default();
|
||||
let args = get_filetime_args(vec!["dust", "--filetime", "accessed"]);
|
||||
assert_eq!(c.get_filetime(&args), Some(FileTime::Accessed));
|
||||
|
||||
// Config is not defined and flag is defined as modified time
|
||||
let c = Config::default();
|
||||
let args = get_filetime_args(vec!["dust", "--filetime", "m"]);
|
||||
assert_eq!(c.get_filetime(&args), Some(FileTime::Modified));
|
||||
|
||||
let c = Config::default();
|
||||
let args = get_filetime_args(vec!["dust", "--filetime", "modified"]);
|
||||
assert_eq!(c.get_filetime(&args), Some(FileTime::Modified));
|
||||
|
||||
// Config is not defined and flag is defined as changed time
|
||||
let c = Config::default();
|
||||
let args = get_filetime_args(vec!["dust", "--filetime", "c"]);
|
||||
assert_eq!(c.get_filetime(&args), Some(FileTime::Changed));
|
||||
|
||||
let c = Config::default();
|
||||
let args = get_filetime_args(vec!["dust", "--filetime", "changed"]);
|
||||
assert_eq!(c.get_filetime(&args), Some(FileTime::Changed));
|
||||
}
|
||||
|
||||
fn get_filetime_args(args: Vec<&str>) -> ArgMatches {
|
||||
Command::new("Dust")
|
||||
.arg(
|
||||
Arg::new("filetime")
|
||||
.short('m')
|
||||
.long("filetime")
|
||||
.num_args(1)
|
||||
.value_parser([
|
||||
PossibleValue::new("a").alias("accessed"),
|
||||
PossibleValue::new("c").alias("changed"),
|
||||
PossibleValue::new("m").alias("modified"),
|
||||
])
|
||||
.help("Directory 'size' is max filetime of child files instead of disk size. while a/c/m for accessed/changed/modified time"),
|
||||
)
|
||||
.get_matches_from(args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use std::cmp::Ordering;
|
||||
use std::fs;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
@@ -7,6 +8,7 @@ use crate::progress::Operation;
|
||||
use crate::progress::PAtomicInfo;
|
||||
use crate::progress::RuntimeErrors;
|
||||
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_regex;
|
||||
use rayon::iter::ParallelBridge;
|
||||
@@ -19,14 +21,27 @@ use std::collections::HashSet;
|
||||
use crate::node::build_node;
|
||||
use std::fs::DirEntry;
|
||||
|
||||
use crate::node::FileTime;
|
||||
use crate::platform::get_metadata;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Operator {
|
||||
Equal = 0,
|
||||
LessThan = 1,
|
||||
GreaterThan = 2,
|
||||
}
|
||||
|
||||
pub struct WalkData<'a> {
|
||||
pub ignore_directories: HashSet<PathBuf>,
|
||||
pub filter_regex: &'a [Regex],
|
||||
pub invert_filter_regex: &'a [Regex],
|
||||
pub allowed_filesystems: HashSet<u64>,
|
||||
pub filter_modified_time: Option<(Operator, i64)>,
|
||||
pub filter_accessed_time: Option<(Operator, i64)>,
|
||||
pub filter_changed_time: Option<(Operator, i64)>,
|
||||
pub use_apparent_size: bool,
|
||||
pub by_filecount: bool,
|
||||
pub by_filetime: &'a Option<FileTime>,
|
||||
pub ignore_hidden: bool,
|
||||
pub follow_links: bool,
|
||||
pub progress_data: Arc<PAtomicInfo>,
|
||||
@@ -44,19 +59,15 @@ pub fn walk_it(dirs: HashSet<PathBuf>, walk_data: &WalkData) -> Vec<Node> {
|
||||
|
||||
prog_data.state.store(Operation::PREPARING, ORDERING);
|
||||
|
||||
clean_inodes(node, &mut inodes, walk_data.use_apparent_size)
|
||||
clean_inodes(node, &mut inodes, walk_data)
|
||||
})
|
||||
.collect();
|
||||
top_level_nodes
|
||||
}
|
||||
|
||||
// Remove files which have the same inode, we don't want to double count them.
|
||||
fn clean_inodes(
|
||||
x: Node,
|
||||
inodes: &mut HashSet<(u64, u64)>,
|
||||
use_apparent_size: bool,
|
||||
) -> Option<Node> {
|
||||
if !use_apparent_size {
|
||||
fn clean_inodes(x: Node, inodes: &mut HashSet<(u64, u64)>, walk_data: &WalkData) -> Option<Node> {
|
||||
if !walk_data.use_apparent_size {
|
||||
if let Some(id) = x.inode_device {
|
||||
if !inodes.insert(id) {
|
||||
return None;
|
||||
@@ -69,12 +80,25 @@ fn clean_inodes(
|
||||
tmp.sort_by(sort_by_inode);
|
||||
let new_children: Vec<_> = tmp
|
||||
.into_iter()
|
||||
.filter_map(|c| clean_inodes(c, inodes, use_apparent_size))
|
||||
.filter_map(|c| clean_inodes(c, inodes, walk_data))
|
||||
.collect();
|
||||
|
||||
let actual_size = if walk_data.by_filetime.is_some() {
|
||||
// If by_filetime is Some, directory 'size' is the maximum filetime among child files instead of disk size
|
||||
new_children
|
||||
.iter()
|
||||
.map(|c| c.size)
|
||||
.chain(std::iter::once(x.size))
|
||||
.max()
|
||||
.unwrap_or(0)
|
||||
} else {
|
||||
// If by_filetime is None, directory 'size' is the sum of disk sizes or file counts of child files
|
||||
x.size + new_children.iter().map(|c| c.size).sum::<u64>()
|
||||
};
|
||||
|
||||
Some(Node {
|
||||
name: x.name,
|
||||
size: x.size + new_children.iter().map(|c| c.size).sum::<u64>(),
|
||||
size: actual_size,
|
||||
children: new_children,
|
||||
inode_device: x.inode_device,
|
||||
depth: x.depth,
|
||||
@@ -83,31 +107,56 @@ fn clean_inodes(
|
||||
|
||||
fn sort_by_inode(a: &Node, b: &Node) -> std::cmp::Ordering {
|
||||
// Sorting by inode is quicker than by sorting by name/size
|
||||
if let Some(x) = a.inode_device {
|
||||
if let Some(y) = b.inode_device {
|
||||
match (a.inode_device, b.inode_device) {
|
||||
(Some(x), Some(y)) => {
|
||||
if x.0 != y.0 {
|
||||
return x.0.cmp(&y.0);
|
||||
x.0.cmp(&y.0)
|
||||
} 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 {
|
||||
let is_dot_file = entry.file_name().to_str().unwrap_or("").starts_with('.');
|
||||
let is_ignored_path = walk_data.ignore_directories.contains(&entry.path());
|
||||
let follow_links = walk_data.follow_links && entry.file_type().is_ok_and(|ft| ft.is_symlink());
|
||||
|
||||
if !walk_data.allowed_filesystems.is_empty() {
|
||||
let size_inode_device = get_metadata(&entry.path(), false);
|
||||
|
||||
if let Some((_size, Some((_id, dev)))) = size_inode_device {
|
||||
let size_inode_device = get_metadata(entry.path(), false, follow_links);
|
||||
if let Some((_size, Some((_id, dev)), _gunk)) = size_inode_device {
|
||||
if !walk_data.allowed_filesystems.contains(&dev) {
|
||||
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, follow_links);
|
||||
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
|
||||
if !walk_data.filter_regex.is_empty()
|
||||
@@ -131,6 +180,10 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
||||
let prog_data = &walk_data.progress_data;
|
||||
let errors = &walk_data.errors;
|
||||
|
||||
if errors.lock().unwrap().abort {
|
||||
return None;
|
||||
}
|
||||
|
||||
let children = if dir.is_dir() {
|
||||
let read_dir = fs::read_dir(&dir);
|
||||
match read_dir {
|
||||
@@ -139,44 +192,46 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
||||
.into_iter()
|
||||
.par_bridge()
|
||||
.filter_map(|entry| {
|
||||
if let Ok(ref entry) = entry {
|
||||
// uncommenting the below line gives simpler code but
|
||||
// rayon doesn't parallelize as well giving a 3X performance drop
|
||||
// hence we unravel the recursion a bit
|
||||
match entry {
|
||||
Ok(ref entry) => {
|
||||
// uncommenting the below line gives simpler code but
|
||||
// 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 let Ok(data) = entry.file_type() {
|
||||
if data.is_dir()
|
||||
|| (walk_data.follow_links && data.is_symlink())
|
||||
{
|
||||
return walk(entry.path(), walk_data, depth + 1);
|
||||
if !ignore_file(entry, walk_data) {
|
||||
if let Ok(data) = entry.file_type() {
|
||||
if data.is_dir()
|
||||
|| (walk_data.follow_links && data.is_symlink())
|
||||
{
|
||||
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 {
|
||||
let mut editable_error = errors.lock().unwrap();
|
||||
editable_error.no_permissions = true
|
||||
Err(ref failed) => {
|
||||
let mut editable_error = errors.lock().unwrap();
|
||||
editable_error.no_permissions.insert(failed.to_string());
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
@@ -186,7 +241,9 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
||||
let mut editable_error = errors.lock().unwrap();
|
||||
match failed.kind() {
|
||||
std::io::ErrorKind::PermissionDenied => {
|
||||
editable_error.no_permissions = true;
|
||||
editable_error
|
||||
.no_permissions
|
||||
.insert(dir.to_string_lossy().into());
|
||||
}
|
||||
std::io::ErrorKind::NotFound => {
|
||||
editable_error.file_not_found.insert(failed.to_string());
|
||||
@@ -206,20 +263,19 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
||||
}
|
||||
vec![]
|
||||
};
|
||||
build_node(
|
||||
dir,
|
||||
children,
|
||||
walk_data.filter_regex,
|
||||
walk_data.invert_filter_regex,
|
||||
walk_data.use_apparent_size,
|
||||
false,
|
||||
false,
|
||||
walk_data.by_filecount,
|
||||
depth,
|
||||
)
|
||||
let is_symlink = if walk_data.follow_links {
|
||||
match fs::symlink_metadata(&dir) {
|
||||
Ok(metadata) => metadata.file_type().is_symlink(),
|
||||
Err(_) => false,
|
||||
}
|
||||
} else {
|
||||
false
|
||||
};
|
||||
build_node(dir, children, is_symlink, false, depth, walk_data)
|
||||
}
|
||||
|
||||
mod tests {
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
|
||||
@@ -234,17 +290,43 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn create_walker<'a>(use_apparent_size: bool) -> WalkData<'a> {
|
||||
use crate::PIndicator;
|
||||
let indicator = PIndicator::build_me();
|
||||
WalkData {
|
||||
ignore_directories: HashSet::new(),
|
||||
filter_regex: &[],
|
||||
invert_filter_regex: &[],
|
||||
allowed_filesystems: HashSet::new(),
|
||||
filter_modified_time: Some((Operator::GreaterThan, 0)),
|
||||
filter_accessed_time: Some((Operator::GreaterThan, 0)),
|
||||
filter_changed_time: Some((Operator::GreaterThan, 0)),
|
||||
use_apparent_size,
|
||||
by_filecount: false,
|
||||
by_filetime: &None,
|
||||
ignore_hidden: false,
|
||||
follow_links: false,
|
||||
progress_data: indicator.data.clone(),
|
||||
errors: Arc::new(Mutex::new(RuntimeErrors::default())),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::redundant_clone)]
|
||||
fn test_should_ignore_file() {
|
||||
let mut inodes = HashSet::new();
|
||||
let n = create_node();
|
||||
let walkdata = create_walker(false);
|
||||
|
||||
// First time we insert the node
|
||||
assert_eq!(clean_inodes(n.clone(), &mut inodes, false), Some(n.clone()));
|
||||
assert_eq!(
|
||||
clean_inodes(n.clone(), &mut inodes, &walkdata),
|
||||
Some(n.clone())
|
||||
);
|
||||
|
||||
// Second time is a duplicate - we ignore it
|
||||
assert_eq!(clean_inodes(n.clone(), &mut inodes, false), None);
|
||||
assert_eq!(clean_inodes(n.clone(), &mut inodes, &walkdata), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -252,9 +334,53 @@ mod tests {
|
||||
fn test_should_not_ignore_files_if_using_apparent_size() {
|
||||
let mut inodes = HashSet::new();
|
||||
let n = create_node();
|
||||
let walkdata = create_walker(true);
|
||||
|
||||
// If using apparent size we include Nodes, even if duplicate inodes
|
||||
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, &walkdata),
|
||||
Some(n.clone())
|
||||
);
|
||||
assert_eq!(
|
||||
clean_inodes(n.clone(), &mut inodes, &walkdata),
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
185
src/display.rs
185
src/display.rs
@@ -1,4 +1,5 @@
|
||||
use crate::display_node::DisplayNode;
|
||||
use crate::node::FileTime;
|
||||
|
||||
use ansi_term::Colour::Red;
|
||||
use lscolors::{LsColors, Style};
|
||||
@@ -7,6 +8,7 @@ use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use stfu8::encode_u8;
|
||||
|
||||
use chrono::{DateTime, Local, TimeZone, Utc};
|
||||
use std::cmp::max;
|
||||
use std::cmp::min;
|
||||
use std::fs;
|
||||
@@ -14,16 +16,18 @@ use std::iter::repeat;
|
||||
use std::path::Path;
|
||||
use thousands::Separable;
|
||||
|
||||
pub static UNITS: [char; 4] = ['T', 'G', 'M', 'K'];
|
||||
pub static UNITS: [char; 5] = ['P', 'T', 'G', 'M', 'K'];
|
||||
static BLOCKS: [char; 5] = ['█', '▓', '▒', '░', ' '];
|
||||
const FILETIME_SHOW_LENGTH: usize = 19;
|
||||
|
||||
pub struct InitialDisplayData {
|
||||
pub short_paths: bool,
|
||||
pub is_reversed: bool,
|
||||
pub colors_on: bool,
|
||||
pub by_filecount: bool,
|
||||
pub by_filetime: Option<FileTime>,
|
||||
pub is_screen_reader: bool,
|
||||
pub iso: bool,
|
||||
pub output_format: String,
|
||||
pub bars_on_right: bool,
|
||||
}
|
||||
|
||||
@@ -130,19 +134,13 @@ pub fn draw_it(
|
||||
root_node: &DisplayNode,
|
||||
skip_total: bool,
|
||||
) {
|
||||
let biggest = match skip_total {
|
||||
false => root_node,
|
||||
true => root_node
|
||||
.get_children_from_node(false)
|
||||
.next()
|
||||
.unwrap_or(root_node),
|
||||
};
|
||||
|
||||
let num_chars_needed_on_left_most = if idd.by_filecount {
|
||||
let max_size = biggest.size;
|
||||
let max_size = root_node.size;
|
||||
max_size.separate_with_commas().chars().count()
|
||||
} else if idd.by_filetime.is_some() {
|
||||
FILETIME_SHOW_LENGTH
|
||||
} else {
|
||||
find_biggest_size_str(root_node, idd.iso)
|
||||
find_biggest_size_str(root_node, &idd.output_format)
|
||||
};
|
||||
|
||||
assert!(
|
||||
@@ -166,7 +164,7 @@ pub fn draw_it(
|
||||
let display_data = DisplayData {
|
||||
initial: idd,
|
||||
num_chars_needed_on_left_most,
|
||||
base_size: biggest.size,
|
||||
base_size: root_node.size,
|
||||
longest_string_length,
|
||||
ls_colors: LsColors::from_env().unwrap_or_default(),
|
||||
};
|
||||
@@ -190,10 +188,12 @@ pub fn draw_it(
|
||||
}
|
||||
}
|
||||
|
||||
fn find_biggest_size_str(node: &DisplayNode, iso: bool) -> usize {
|
||||
let mut mx = human_readable_number(node.size, iso).chars().count();
|
||||
fn find_biggest_size_str(node: &DisplayNode, output_format: &str) -> usize {
|
||||
let mut mx = human_readable_number(node.size, output_format)
|
||||
.chars()
|
||||
.count();
|
||||
for n in node.children.iter() {
|
||||
mx = max(mx, find_biggest_size_str(n, iso));
|
||||
mx = max(mx, find_biggest_size_str(n, output_format));
|
||||
}
|
||||
mx
|
||||
}
|
||||
@@ -340,6 +340,8 @@ pub fn format_string(
|
||||
if display_data.initial.is_screen_reader {
|
||||
// if screen_reader then bars is 'depth'
|
||||
format!("{pretty_name} {bars} {pretty_size}{percent}")
|
||||
} else if display_data.initial.by_filetime.is_some() {
|
||||
format!("{pretty_size} {indent}{pretty_name}")
|
||||
} else {
|
||||
format!("{pretty_size} {indent} {pretty_name}{percent}")
|
||||
}
|
||||
@@ -374,8 +376,10 @@ fn get_name_percent(
|
||||
fn get_pretty_size(node: &DisplayNode, is_biggest: bool, display_data: &DisplayData) -> String {
|
||||
let output = if display_data.initial.by_filecount {
|
||||
node.size.separate_with_commas()
|
||||
} else if display_data.initial.by_filetime.is_some() {
|
||||
get_pretty_file_modified_time(node.size as i64)
|
||||
} else {
|
||||
human_readable_number(node.size, display_data.initial.iso)
|
||||
human_readable_number(node.size, &display_data.initial.output_format)
|
||||
};
|
||||
let spaces_to_add = display_data.num_chars_needed_on_left_most - output.chars().count();
|
||||
let output = " ".repeat(spaces_to_add) + output.as_str();
|
||||
@@ -387,6 +391,14 @@ fn get_pretty_size(node: &DisplayNode, is_biggest: bool, display_data: &DisplayD
|
||||
}
|
||||
}
|
||||
|
||||
fn get_pretty_file_modified_time(timestamp: i64) -> String {
|
||||
let datetime: DateTime<Utc> = Utc.timestamp_opt(timestamp, 0).unwrap();
|
||||
|
||||
let local_datetime = datetime.with_timezone(&Local);
|
||||
|
||||
local_datetime.format("%Y-%m-%dT%H:%M:%S").to_string()
|
||||
}
|
||||
|
||||
fn get_pretty_name(
|
||||
node: &DisplayNode,
|
||||
name_and_padding: String,
|
||||
@@ -407,19 +419,51 @@ fn get_pretty_name(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn human_readable_number(size: u64, iso: bool) -> String {
|
||||
// If we are working with SI units or not
|
||||
pub fn get_type_of_thousand(output_str: &str) -> u64 {
|
||||
if output_str.is_empty() {
|
||||
1024
|
||||
} else if output_str == "si" {
|
||||
1000
|
||||
} else if output_str.contains('i') || output_str.len() == 1 {
|
||||
1024
|
||||
} else {
|
||||
1000
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_number_format(output_str: &str) -> Option<(u64, char)> {
|
||||
if output_str.starts_with('b') {
|
||||
return Some((1, 'B'));
|
||||
}
|
||||
for (i, u) in UNITS.iter().enumerate() {
|
||||
let num: u64 = if iso { 1000 } else { 1024 };
|
||||
let marker = num.pow((UNITS.len() - i) as u32);
|
||||
if size >= marker {
|
||||
if size / marker < 10 {
|
||||
return format!("{:.1}{}", (size as f32 / marker as f32), u);
|
||||
} else {
|
||||
return format!("{}{}", (size / marker), u);
|
||||
}
|
||||
if output_str.starts_with((*u).to_ascii_lowercase()) {
|
||||
let marker = get_type_of_thousand(output_str).pow((UNITS.len() - i) as u32);
|
||||
return Some((marker, *u));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn human_readable_number(size: u64, output_str: &str) -> String {
|
||||
match get_number_format(output_str) {
|
||||
Some((x, u)) => {
|
||||
format!("{}{}", (size / x), u)
|
||||
}
|
||||
None => {
|
||||
for (i, u) in UNITS.iter().enumerate() {
|
||||
let marker = get_type_of_thousand(output_str).pow((UNITS.len() - i) as u32);
|
||||
if size >= marker {
|
||||
if size / marker < 10 {
|
||||
return format!("{:.1}{}", (size as f32 / marker as f32), u);
|
||||
} else {
|
||||
return format!("{}{}", (size / marker), u);
|
||||
}
|
||||
}
|
||||
}
|
||||
format!("{size}B")
|
||||
}
|
||||
}
|
||||
format!("{size}B")
|
||||
}
|
||||
|
||||
mod tests {
|
||||
@@ -435,8 +479,9 @@ mod tests {
|
||||
is_reversed: false,
|
||||
colors_on: false,
|
||||
by_filecount: false,
|
||||
by_filetime: None,
|
||||
is_screen_reader: false,
|
||||
iso: false,
|
||||
output_format: "".into(),
|
||||
bars_on_right: false,
|
||||
};
|
||||
DisplayData {
|
||||
@@ -503,26 +548,51 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_human_readable_number() {
|
||||
assert_eq!(human_readable_number(1, false), "1B");
|
||||
assert_eq!(human_readable_number(956, false), "956B");
|
||||
assert_eq!(human_readable_number(1004, false), "1004B");
|
||||
assert_eq!(human_readable_number(1024, false), "1.0K");
|
||||
assert_eq!(human_readable_number(1536, false), "1.5K");
|
||||
assert_eq!(human_readable_number(1024 * 512, false), "512K");
|
||||
assert_eq!(human_readable_number(1024 * 1024, false), "1.0M");
|
||||
assert_eq!(human_readable_number(1, ""), "1B");
|
||||
assert_eq!(human_readable_number(956, ""), "956B");
|
||||
assert_eq!(human_readable_number(1004, ""), "1004B");
|
||||
assert_eq!(human_readable_number(1024, ""), "1.0K");
|
||||
assert_eq!(human_readable_number(1536, ""), "1.5K");
|
||||
assert_eq!(human_readable_number(1024 * 512, ""), "512K");
|
||||
assert_eq!(human_readable_number(1024 * 1024, ""), "1.0M");
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 - 1, ""), "1023M");
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 * 20, ""), "20G");
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 * 1024, ""), "1.0T");
|
||||
assert_eq!(
|
||||
human_readable_number(1024 * 1024 * 1024 - 1, false),
|
||||
"1023M"
|
||||
human_readable_number(1024 * 1024 * 1024 * 1024 * 234, ""),
|
||||
"234T"
|
||||
);
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 * 20, false), "20G");
|
||||
assert_eq!(
|
||||
human_readable_number(1024 * 1024 * 1024 * 1024, false),
|
||||
"1.0T"
|
||||
human_readable_number(1024 * 1024 * 1024 * 1024 * 1024, ""),
|
||||
"1.0P"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_human_readable_number_si() {
|
||||
assert_eq!(human_readable_number(1024 * 100, ""), "100K");
|
||||
assert_eq!(human_readable_number(1024 * 100, "si"), "102K");
|
||||
}
|
||||
|
||||
// Refer to https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
|
||||
#[test]
|
||||
fn test_human_readable_number_kb() {
|
||||
let hrn = human_readable_number;
|
||||
assert_eq!(hrn(1023, "b"), "1023B");
|
||||
assert_eq!(hrn(1000 * 1000, "bytes"), "1000000B");
|
||||
assert_eq!(hrn(1023, "kb"), "1K");
|
||||
assert_eq!(hrn(1023, "k"), "0K");
|
||||
assert_eq!(hrn(1023, "kib"), "0K");
|
||||
assert_eq!(hrn(1024, "kib"), "1K");
|
||||
assert_eq!(hrn(1024 * 512, "kib"), "512K");
|
||||
assert_eq!(hrn(1024 * 1024, "kib"), "1024K");
|
||||
assert_eq!(hrn(1024 * 1000 * 1000 * 20, "kib"), "20000000K");
|
||||
assert_eq!(hrn(1024 * 1024 * 1000 * 20, "mib"), "20000M");
|
||||
assert_eq!(hrn(1024 * 1024 * 1024 * 20, "gib"), "20G");
|
||||
}
|
||||
|
||||
#[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 {
|
||||
name: PathBuf::from("/short"),
|
||||
size: 2_u64.pow(size),
|
||||
@@ -574,4 +644,37 @@ mod tests {
|
||||
let bar = dd.generate_bar(&n, 5);
|
||||
assert_eq!(bar, "████▓▓▓▓▓▓▓▓▓");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_pretty_file_modified_time() {
|
||||
// Create a timestamp for 2023-07-12 00:00:00 in local time
|
||||
let local_dt = Local.with_ymd_and_hms(2023, 7, 12, 0, 0, 0).unwrap();
|
||||
let timestamp = local_dt.timestamp();
|
||||
|
||||
// Format expected output
|
||||
let expected_output = local_dt.format("%Y-%m-%dT%H:%M:%S").to_string();
|
||||
|
||||
assert_eq!(get_pretty_file_modified_time(timestamp), expected_output);
|
||||
|
||||
// Test another timestamp
|
||||
let local_dt = Local.with_ymd_and_hms(2020, 1, 1, 12, 0, 0).unwrap();
|
||||
let timestamp = local_dt.timestamp();
|
||||
let expected_output = local_dt.format("%Y-%m-%dT%H:%M:%S").to_string();
|
||||
|
||||
assert_eq!(get_pretty_file_modified_time(timestamp), expected_output);
|
||||
|
||||
// Test timestamp for epoch start (1970-01-01T00:00:00)
|
||||
let local_dt = Local.with_ymd_and_hms(1970, 1, 1, 0, 0, 0).unwrap();
|
||||
let timestamp = local_dt.timestamp();
|
||||
let expected_output = local_dt.format("%Y-%m-%dT%H:%M:%S").to_string();
|
||||
|
||||
assert_eq!(get_pretty_file_modified_time(timestamp), expected_output);
|
||||
|
||||
// Test a future timestamp
|
||||
let local_dt = Local.with_ymd_and_hms(2030, 12, 25, 6, 30, 0).unwrap();
|
||||
let timestamp = local_dt.timestamp();
|
||||
let expected_output = local_dt.format("%Y-%m-%dT%H:%M:%S").to_string();
|
||||
|
||||
assert_eq!(get_pretty_file_modified_time(timestamp), expected_output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
use std::cell::RefCell;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use serde::ser::SerializeStruct;
|
||||
use serde::{Serialize, Serializer};
|
||||
|
||||
use crate::display::human_readable_number;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
||||
pub struct DisplayNode {
|
||||
// Note: the order of fields in important here, for PartialEq and PartialOrd
|
||||
@@ -23,3 +29,30 @@ impl DisplayNode {
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
// Only used for -j 'json' flag combined with -o 'output_type' flag
|
||||
// Used to pass the output_type into the custom Serde serializer
|
||||
thread_local! {
|
||||
pub static OUTPUT_TYPE: RefCell<String> = const { RefCell::new(String::new()) };
|
||||
}
|
||||
|
||||
/*
|
||||
We need the custom Serialize incase someone uses the -o flag to pass a custom output type in
|
||||
(show size in Mb / Gb etc).
|
||||
Sadly this also necessitates a global variable OUTPUT_TYPE as we can not pass the output_type flag
|
||||
into the serialize method
|
||||
*/
|
||||
impl Serialize for DisplayNode {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let readable_size = OUTPUT_TYPE
|
||||
.with(|output_type| human_readable_number(self.size, output_type.borrow().as_str()));
|
||||
let mut state = serializer.serialize_struct("DisplayNode", 2)?;
|
||||
state.serialize_field("size", &(readable_size))?;
|
||||
state.serialize_field("name", &self.name)?;
|
||||
state.serialize_field("children", &self.children)?;
|
||||
state.end()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::display_node::DisplayNode;
|
||||
use crate::node::FileTime;
|
||||
use crate::node::Node;
|
||||
use std::collections::BinaryHeap;
|
||||
use std::collections::HashMap;
|
||||
@@ -14,7 +15,11 @@ pub struct AggregateData {
|
||||
pub using_a_filter: bool,
|
||||
}
|
||||
|
||||
pub fn get_biggest(top_level_nodes: Vec<Node>, display_data: AggregateData) -> Option<DisplayNode> {
|
||||
pub fn get_biggest(
|
||||
top_level_nodes: Vec<Node>,
|
||||
display_data: AggregateData,
|
||||
by_filetime: &Option<FileTime>,
|
||||
) -> Option<DisplayNode> {
|
||||
if top_level_nodes.is_empty() {
|
||||
// perhaps change this, bring back Error object?
|
||||
return None;
|
||||
@@ -24,7 +29,15 @@ pub fn get_biggest(top_level_nodes: Vec<Node>, display_data: AggregateData) -> O
|
||||
let root;
|
||||
|
||||
if number_top_level_nodes > 1 {
|
||||
let size = top_level_nodes.iter().map(|node| node.size).sum();
|
||||
let size = if by_filetime.is_some() {
|
||||
top_level_nodes
|
||||
.iter()
|
||||
.map(|node| node.size)
|
||||
.max()
|
||||
.unwrap_or(0)
|
||||
} else {
|
||||
top_level_nodes.iter().map(|node| node.size).sum()
|
||||
};
|
||||
root = Node {
|
||||
name: PathBuf::from("(total)"),
|
||||
size,
|
||||
@@ -114,7 +127,7 @@ fn recursive_rebuilder(allowed_nodes: &HashMap<&Path, &Node>, current: &Node) ->
|
||||
.map(|c| recursive_rebuilder(allowed_nodes, c))
|
||||
.collect();
|
||||
|
||||
build_node(new_children, current)
|
||||
build_display_node(new_children, current)
|
||||
}
|
||||
|
||||
// Applies all allowed nodes as children to current node
|
||||
@@ -127,10 +140,10 @@ fn flat_rebuilder(allowed_nodes: HashMap<&Path, &Node>, current: &Node) -> Displ
|
||||
children: vec![],
|
||||
})
|
||||
.collect::<Vec<DisplayNode>>();
|
||||
build_node(new_children, current)
|
||||
build_display_node(new_children, current)
|
||||
}
|
||||
|
||||
fn build_node(mut new_children: Vec<DisplayNode>, current: &Node) -> DisplayNode {
|
||||
fn build_display_node(mut new_children: Vec<DisplayNode>, current: &Node) -> DisplayNode {
|
||||
new_children.sort_by(|lhs, rhs| lhs.cmp(rhs).reverse());
|
||||
DisplayNode {
|
||||
name: current.name.clone(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::display_node::DisplayNode;
|
||||
use crate::node::FileTime;
|
||||
use crate::node::Node;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsStr;
|
||||
@@ -10,7 +11,11 @@ struct ExtensionNode<'a> {
|
||||
extension: Option<&'a OsStr>,
|
||||
}
|
||||
|
||||
pub fn get_all_file_types(top_level_nodes: &[Node], n: usize) -> Option<DisplayNode> {
|
||||
pub fn get_all_file_types(
|
||||
top_level_nodes: &[Node],
|
||||
n: usize,
|
||||
by_filetime: &Option<FileTime>,
|
||||
) -> Option<DisplayNode> {
|
||||
let ext_nodes = {
|
||||
let mut extension_cumulative_sizes = HashMap::new();
|
||||
build_by_all_file_types(top_level_nodes, &mut extension_cumulative_sizes);
|
||||
@@ -44,16 +49,27 @@ pub fn get_all_file_types(top_level_nodes: &[Node], n: usize) -> Option<DisplayN
|
||||
|
||||
// ...then, aggregate the remaining nodes (if any) into a single "(others)" node
|
||||
if ext_nodes_iter.len() > 0 {
|
||||
let actual_size = if by_filetime.is_some() {
|
||||
ext_nodes_iter.map(|node| node.size).max().unwrap_or(0)
|
||||
} else {
|
||||
ext_nodes_iter.map(|node| node.size).sum()
|
||||
};
|
||||
displayed.push(DisplayNode {
|
||||
name: PathBuf::from("(others)"),
|
||||
size: ext_nodes_iter.map(|node| node.size).sum(),
|
||||
size: actual_size,
|
||||
children: vec![],
|
||||
});
|
||||
}
|
||||
|
||||
let actual_size: u64 = if by_filetime.is_some() {
|
||||
displayed.iter().map(|node| node.size).max().unwrap_or(0)
|
||||
} else {
|
||||
displayed.iter().map(|node| node.size).sum()
|
||||
};
|
||||
|
||||
let result = DisplayNode {
|
||||
name: PathBuf::from("(total)"),
|
||||
size: displayed.iter().map(|node| node.size).sum(),
|
||||
size: actual_size,
|
||||
children: displayed,
|
||||
};
|
||||
|
||||
|
||||
258
src/main.rs
258
src/main.rs
@@ -19,9 +19,13 @@ use filter::AggregateData;
|
||||
use progress::PIndicator;
|
||||
use regex::Error;
|
||||
use std::collections::HashSet;
|
||||
use std::env;
|
||||
use std::fs::read_to_string;
|
||||
use std::io;
|
||||
use std::panic;
|
||||
use std::process;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use sysinfo::{System, SystemExt};
|
||||
@@ -29,6 +33,7 @@ use sysinfo::{System, SystemExt};
|
||||
use self::display::draw_it;
|
||||
use config::get_config;
|
||||
use dir_walker::walk_it;
|
||||
use display_node::OUTPUT_TYPE;
|
||||
use filter::get_biggest;
|
||||
use filter_type::get_all_file_types;
|
||||
use regex::Regex;
|
||||
@@ -41,50 +46,55 @@ use utils::simplify_dir_names;
|
||||
static DEFAULT_NUMBER_OF_LINES: usize = 30;
|
||||
static DEFAULT_TERMINAL_WIDTH: usize = 80;
|
||||
|
||||
fn init_color(no_color: bool) -> bool {
|
||||
fn should_init_color(no_color: bool, force_color: bool) -> bool {
|
||||
if force_color {
|
||||
return true;
|
||||
}
|
||||
if no_color {
|
||||
return false;
|
||||
}
|
||||
// check if NO_COLOR is set
|
||||
// https://no-color.org/
|
||||
if env::var_os("NO_COLOR").is_some() {
|
||||
return false;
|
||||
}
|
||||
if terminal_size().is_none() {
|
||||
// we are not in a terminal, color may not be needed
|
||||
return false;
|
||||
}
|
||||
// we are in a terminal
|
||||
#[cfg(windows)]
|
||||
{
|
||||
// If no color is already set do not print a warning message
|
||||
if no_color {
|
||||
true
|
||||
} else {
|
||||
// Required for windows 10
|
||||
// Fails to resolve for windows 8 so disable color
|
||||
match ansi_term::enable_ansi_support() {
|
||||
Ok(_) => no_color,
|
||||
Err(_) => {
|
||||
eprintln!(
|
||||
"This version of Windows does not support ANSI colors, setting no_color flag"
|
||||
);
|
||||
true
|
||||
}
|
||||
// Required for windows 10
|
||||
// Fails to resolve for windows 8 so disable color
|
||||
match ansi_term::enable_ansi_support() {
|
||||
Ok(_) => true,
|
||||
Err(_) => {
|
||||
eprintln!("This version of Windows does not support ANSI colors");
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
no_color
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
fn get_height_of_terminal() -> usize {
|
||||
// Simplify once https://github.com/eminence/terminal-size/pull/41 is
|
||||
// merged
|
||||
terminal_size()
|
||||
// Windows CI runners detect a terminal height of 0
|
||||
.map(|(_, Height(h))| max(h as usize, DEFAULT_NUMBER_OF_LINES))
|
||||
.map(|(_, Height(h))| max(h.into(), DEFAULT_NUMBER_OF_LINES))
|
||||
.unwrap_or(DEFAULT_NUMBER_OF_LINES)
|
||||
- 10
|
||||
}
|
||||
|
||||
fn get_width_of_terminal() -> usize {
|
||||
// Simplify once https://github.com/eminence/terminal-size/pull/41 is
|
||||
// merged
|
||||
terminal_size()
|
||||
.map(|(Width(w), _)| match cfg!(windows) {
|
||||
// Windows CI runners detect a very low terminal width
|
||||
true => max(w as usize, DEFAULT_TERMINAL_WIDTH),
|
||||
false => w as usize,
|
||||
true => max(w.into(), DEFAULT_TERMINAL_WIDTH),
|
||||
false => w.into(),
|
||||
})
|
||||
.unwrap_or(DEFAULT_TERMINAL_WIDTH)
|
||||
}
|
||||
@@ -103,12 +113,55 @@ fn get_regex_value(maybe_value: Option<ValuesRef<String>>) -> Vec<Regex> {
|
||||
|
||||
fn main() {
|
||||
let options = build_cli().get_matches();
|
||||
let config = get_config();
|
||||
let config = get_config(options.get_one::<String>("config").cloned());
|
||||
|
||||
let target_dirs = match options.get_many::<String>("params") {
|
||||
Some(values) => values.map(|v| v.as_str()).collect::<Vec<&str>>(),
|
||||
None => vec!["."],
|
||||
let errors = RuntimeErrors::default();
|
||||
let error_listen_for_ctrlc = Arc::new(Mutex::new(errors));
|
||||
let errors_for_rayon = 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 || {
|
||||
error_listen_for_ctrlc.lock().unwrap().abort = true;
|
||||
println!("\nAborting");
|
||||
if cloned_is_in_listing.load(Ordering::Relaxed) {
|
||||
process::exit(1);
|
||||
}
|
||||
})
|
||||
.expect("Error setting Ctrl-C handler");
|
||||
|
||||
is_in_listing.store(true, Ordering::Relaxed);
|
||||
let target_dirs = match config.get_files_from(&options) {
|
||||
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");
|
||||
|
||||
@@ -136,7 +189,10 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
let no_colors = init_color(config.get_no_colors(&options));
|
||||
let is_colors = should_init_color(
|
||||
config.get_no_colors(&options),
|
||||
config.get_force_colors(&options),
|
||||
);
|
||||
|
||||
let ignore_directories = match options.get_many::<String>("ignore_directory") {
|
||||
Some(values) => values
|
||||
@@ -165,65 +221,78 @@ fn main() {
|
||||
.collect::<Vec<Regex>>();
|
||||
|
||||
let by_filecount = options.get_flag("by_filecount");
|
||||
let by_filetime = config.get_filetime(&options);
|
||||
let limit_filesystem = options.get_flag("limit_filesystem");
|
||||
let follow_links = options.get_flag("dereference_links");
|
||||
|
||||
let simplified_dirs = simplify_dir_names(target_dirs);
|
||||
let allowed_filesystems = limit_filesystem
|
||||
.then(|| get_filesystem_devices(simplified_dirs.iter()))
|
||||
.then(|| get_filesystem_devices(&target_dirs, follow_links))
|
||||
.unwrap_or_default();
|
||||
let simplified_dirs = simplify_dir_names(&target_dirs);
|
||||
|
||||
let ignored_full_path: HashSet<PathBuf> = ignore_directories
|
||||
.into_iter()
|
||||
.flat_map(|x| simplified_dirs.iter().map(move |d| d.join(&x)))
|
||||
.collect();
|
||||
|
||||
let iso = config.get_iso(&options);
|
||||
let output_format = config.get_output_format(&options);
|
||||
|
||||
let ignore_hidden = config.get_ignore_hidden(&options);
|
||||
|
||||
let mut indicator = PIndicator::build_me();
|
||||
if !config.get_disable_progress(&options) {
|
||||
indicator.spawn(iso);
|
||||
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_changed_time_operator(&options);
|
||||
|
||||
let walk_data = WalkData {
|
||||
ignore_directories: ignored_full_path,
|
||||
filter_regex: &filter_regexs,
|
||||
invert_filter_regex: &invert_filter_regexs,
|
||||
allowed_filesystems,
|
||||
filter_modified_time,
|
||||
filter_accessed_time,
|
||||
filter_changed_time,
|
||||
use_apparent_size: config.get_apparent_size(&options),
|
||||
by_filecount,
|
||||
by_filetime: &by_filetime,
|
||||
ignore_hidden,
|
||||
follow_links,
|
||||
progress_data: indicator.data.clone(),
|
||||
errors: Arc::new(Mutex::new(RuntimeErrors::default())),
|
||||
errors: errors_for_rayon,
|
||||
};
|
||||
let threads_to_use = config.get_threads(&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 tree = match summarize_file_types {
|
||||
true => get_all_file_types(&top_level_nodes, number_of_lines),
|
||||
true => get_all_file_types(&top_level_nodes, number_of_lines, &by_filetime),
|
||||
false => {
|
||||
let agg_data = AggregateData {
|
||||
min_size: config.get_min_size(&options, iso),
|
||||
min_size: config.get_min_size(&options),
|
||||
only_dir: config.get_only_dir(&options),
|
||||
only_file: config.get_only_file(&options),
|
||||
number_of_lines,
|
||||
depth,
|
||||
using_a_filter: !filter_regexs.is_empty() || !invert_filter_regexs.is_empty(),
|
||||
};
|
||||
get_biggest(top_level_nodes, agg_data)
|
||||
get_biggest(top_level_nodes, agg_data, &by_filetime)
|
||||
}
|
||||
};
|
||||
|
||||
// Must have stopped indicator before we print to stderr
|
||||
indicator.stop();
|
||||
|
||||
if errors_final.lock().unwrap().abort {
|
||||
return;
|
||||
}
|
||||
|
||||
let final_errors = walk_data.errors.lock().unwrap();
|
||||
let failed_permissions = final_errors.no_permissions;
|
||||
if !final_errors.file_not_found.is_empty() {
|
||||
let err = final_errors
|
||||
.file_not_found
|
||||
@@ -233,8 +302,20 @@ fn main() {
|
||||
.join(", ");
|
||||
eprintln!("No such file or directory: {}", err);
|
||||
}
|
||||
if failed_permissions {
|
||||
eprintln!("Did not have permissions for all directories");
|
||||
if !final_errors.no_permissions.is_empty() {
|
||||
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() {
|
||||
let err = final_errors
|
||||
@@ -247,53 +328,72 @@ fn main() {
|
||||
}
|
||||
|
||||
if let Some(root_node) = tree {
|
||||
let idd = InitialDisplayData {
|
||||
short_paths: !config.get_full_paths(&options),
|
||||
is_reversed: !config.get_reverse(&options),
|
||||
colors_on: !no_colors,
|
||||
by_filecount,
|
||||
iso,
|
||||
is_screen_reader: config.get_screen_reader(&options),
|
||||
bars_on_right: config.get_bars_on_right(&options),
|
||||
};
|
||||
draw_it(
|
||||
idd,
|
||||
config.get_no_bars(&options),
|
||||
terminal_width,
|
||||
&root_node,
|
||||
config.get_skip_total(&options),
|
||||
)
|
||||
if config.get_output_json(&options) {
|
||||
OUTPUT_TYPE.with(|wrapped| {
|
||||
wrapped.replace(output_format);
|
||||
});
|
||||
println!("{}", serde_json::to_string(&root_node).unwrap());
|
||||
} else {
|
||||
let idd = InitialDisplayData {
|
||||
short_paths: !config.get_full_paths(&options),
|
||||
is_reversed: !config.get_reverse(&options),
|
||||
colors_on: is_colors,
|
||||
by_filecount,
|
||||
by_filetime,
|
||||
is_screen_reader: config.get_screen_reader(&options),
|
||||
output_format,
|
||||
bars_on_right: config.get_bars_on_right(&options),
|
||||
};
|
||||
|
||||
draw_it(
|
||||
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
|
||||
// The global thread pool has not been initialized.: ThreadPoolBuildError { kind: GlobalPoolAlreadyInitialized }
|
||||
if cfg!(target_pointer_width = "64") {
|
||||
let result = panic::catch_unwind(|| {
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
let result = panic::catch_unwind(|| build_thread_pool(*stack_size, *threads));
|
||||
if result.is_err() {
|
||||
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()
|
||||
}
|
||||
|
||||
54
src/node.rs
54
src/node.rs
@@ -1,8 +1,9 @@
|
||||
use crate::dir_walker::WalkData;
|
||||
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_regex;
|
||||
|
||||
use regex::Regex;
|
||||
use std::cmp::Ordering;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -15,33 +16,56 @@ pub struct Node {
|
||||
pub depth: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum FileTime {
|
||||
Modified,
|
||||
Accessed,
|
||||
Changed,
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn build_node(
|
||||
dir: PathBuf,
|
||||
children: Vec<Node>,
|
||||
filter_regex: &[Regex],
|
||||
invert_filter_regex: &[Regex],
|
||||
use_apparent_size: bool,
|
||||
is_symlink: bool,
|
||||
is_file: bool,
|
||||
by_filecount: bool,
|
||||
depth: usize,
|
||||
walk_data: &WalkData,
|
||||
) -> Option<Node> {
|
||||
get_metadata(&dir, use_apparent_size).map(|data| {
|
||||
let inode_device = if is_symlink && !use_apparent_size {
|
||||
None
|
||||
} else {
|
||||
data.1
|
||||
};
|
||||
let use_apparent_size = walk_data.use_apparent_size;
|
||||
let by_filecount = walk_data.by_filecount;
|
||||
let by_filetime = &walk_data.by_filetime;
|
||||
|
||||
let size = if is_filtered_out_due_to_regex(filter_regex, &dir)
|
||||
|| is_filtered_out_due_to_invert_regex(invert_filter_regex, &dir)
|
||||
|| (is_symlink && !use_apparent_size)
|
||||
get_metadata(
|
||||
&dir,
|
||||
use_apparent_size,
|
||||
walk_data.follow_links && is_symlink,
|
||||
)
|
||||
.map(|data| {
|
||||
let inode_device = data.1;
|
||||
|
||||
let size = if is_filtered_out_due_to_regex(walk_data.filter_regex, &dir)
|
||||
|| is_filtered_out_due_to_invert_regex(walk_data.invert_filter_regex, &dir)
|
||||
|| 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
|
||||
} else if by_filecount {
|
||||
1
|
||||
} else if by_filetime.is_some() {
|
||||
match by_filetime {
|
||||
Some(FileTime::Modified) => data.2 .0.unsigned_abs(),
|
||||
Some(FileTime::Accessed) => data.2 .1.unsigned_abs(),
|
||||
Some(FileTime::Changed) => data.2 .2.unsigned_abs(),
|
||||
None => unreachable!(),
|
||||
}
|
||||
} else {
|
||||
data.0
|
||||
};
|
||||
|
||||
@@ -10,15 +10,35 @@ fn get_block_size() -> u64 {
|
||||
512
|
||||
}
|
||||
|
||||
type InodeAndDevice = (u64, u64);
|
||||
type FileTime = (i64, i64, i64);
|
||||
|
||||
#[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,
|
||||
follow_links: bool,
|
||||
) -> Option<(u64, Option<InodeAndDevice>, FileTime)> {
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
match d.metadata() {
|
||||
let metadata = if follow_links {
|
||||
path.as_ref().metadata()
|
||||
} else {
|
||||
path.as_ref().symlink_metadata()
|
||||
};
|
||||
match metadata {
|
||||
Ok(md) => {
|
||||
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 {
|
||||
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,
|
||||
@@ -26,7 +46,11 @@ pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u
|
||||
}
|
||||
|
||||
#[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,
|
||||
follow_links: bool,
|
||||
) -> Option<(u64, Option<InodeAndDevice>, FileTime)> {
|
||||
// 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
|
||||
// windows defender to scan the file.
|
||||
@@ -65,7 +89,7 @@ pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u
|
||||
|
||||
use std::io;
|
||||
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::os::windows::fs::OpenOptionsExt;
|
||||
const FILE_READ_ATTRIBUTES: u32 = 0x0080;
|
||||
@@ -91,30 +115,46 @@ pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u
|
||||
}
|
||||
|
||||
fn get_metadata_expensive(
|
||||
d: &Path,
|
||||
path: &Path,
|
||||
use_apparent_size: bool,
|
||||
) -> Option<(u64, Option<(u64, u64)>)> {
|
||||
) -> Option<(u64, Option<InodeAndDevice>, FileTime)> {
|
||||
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()?;
|
||||
|
||||
if use_apparent_size {
|
||||
use filesize::PathExt;
|
||||
Some((
|
||||
d.size_on_disk().ok()?,
|
||||
path.size_on_disk().ok()?,
|
||||
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 {
|
||||
Some((
|
||||
info.file_size(),
|
||||
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;
|
||||
match d.metadata() {
|
||||
let path = path.as_ref();
|
||||
let metadata = if follow_links {
|
||||
path.metadata()
|
||||
} else {
|
||||
path.symlink_metadata()
|
||||
};
|
||||
match metadata {
|
||||
Ok(ref md) => {
|
||||
const FILE_ATTRIBUTE_ARCHIVE: u32 = 0x20;
|
||||
const FILE_ATTRIBUTE_READONLY: u32 = 0x01;
|
||||
@@ -142,11 +182,19 @@ pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u
|
||||
|| md.file_attributes() == FILE_ATTRIBUTE_NORMAL)
|
||||
&& !((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 {
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{
|
||||
io::Write,
|
||||
path::Path,
|
||||
sync::{
|
||||
atomic::{AtomicU64, AtomicU8, AtomicUsize, Ordering},
|
||||
atomic::{AtomicU8, AtomicUsize, Ordering},
|
||||
mpsc::{self, RecvTimeoutError, Sender},
|
||||
Arc, RwLock,
|
||||
},
|
||||
@@ -11,6 +11,11 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
#[cfg(not(target_has_atomic = "64"))]
|
||||
use portable_atomic::AtomicU64;
|
||||
#[cfg(target_has_atomic = "64")]
|
||||
use std::sync::atomic::AtomicU64;
|
||||
|
||||
use crate::display::human_readable_number;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -70,23 +75,24 @@ impl PAtomicInfo {
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RuntimeErrors {
|
||||
pub no_permissions: bool,
|
||||
pub no_permissions: HashSet<String>,
|
||||
pub file_not_found: HashSet<String>,
|
||||
pub unknown_error: HashSet<String>,
|
||||
pub abort: bool,
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
fn format_preparing_str(prog_char: char, data: &PAtomicInfo, is_iso: bool) -> String {
|
||||
fn format_preparing_str(prog_char: char, data: &PAtomicInfo, output_display: &str) -> String {
|
||||
let path_in = data.current_path.get();
|
||||
let size = human_readable_number(data.total_file_size.load(ORDERING), is_iso);
|
||||
let size = human_readable_number(data.total_file_size.load(ORDERING), output_display);
|
||||
format!("Preparing: {path_in} {size} ... {prog_char}")
|
||||
}
|
||||
|
||||
fn format_indexing_str(prog_char: char, data: &PAtomicInfo, is_iso: bool) -> String {
|
||||
fn format_indexing_str(prog_char: char, data: &PAtomicInfo, output_display: &str) -> String {
|
||||
let path_in = data.current_path.get();
|
||||
let file_count = data.num_files.load(ORDERING);
|
||||
let size = human_readable_number(data.total_file_size.load(ORDERING), is_iso);
|
||||
let size = human_readable_number(data.total_file_size.load(ORDERING), output_display);
|
||||
let file_str = format!("{file_count} files, {size}");
|
||||
format!("Indexing: {path_in} {file_str} ... {prog_char}")
|
||||
}
|
||||
@@ -106,7 +112,7 @@ impl PIndicator {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spawn(&mut self, is_iso: bool) {
|
||||
pub fn spawn(&mut self, output_display: String) {
|
||||
let data = self.data.clone();
|
||||
let (stop_handler, receiver) = mpsc::channel::<()>();
|
||||
|
||||
@@ -125,8 +131,8 @@ impl PIndicator {
|
||||
let prog_char = PROGRESS_CHARS[progress_char_i];
|
||||
|
||||
msg = match data.state.load(ORDERING) {
|
||||
Operation::INDEXING => format_indexing_str(prog_char, &data, is_iso),
|
||||
Operation::PREPARING => format_preparing_str(prog_char, &data, is_iso),
|
||||
Operation::INDEXING => format_indexing_str(prog_char, &data, &output_display),
|
||||
Operation::PREPARING => format_preparing_str(prog_char, &data, &output_display),
|
||||
_ => panic!("Unknown State"),
|
||||
};
|
||||
|
||||
|
||||
59
src/utils.rs
59
src/utils.rs
@@ -2,13 +2,16 @@ use platform::get_metadata;
|
||||
use std::collections::HashSet;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::config::DAY_SECONDS;
|
||||
|
||||
use crate::dir_walker::Operator;
|
||||
use crate::platform;
|
||||
use regex::Regex;
|
||||
|
||||
pub fn simplify_dir_names<P: AsRef<Path>>(filenames: Vec<P>) -> HashSet<PathBuf> {
|
||||
let mut top_level_names: HashSet<PathBuf> = HashSet::with_capacity(filenames.len());
|
||||
pub fn simplify_dir_names<P: AsRef<Path>>(dirs: &[P]) -> HashSet<PathBuf> {
|
||||
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 mut can_add = true;
|
||||
let mut to_remove: Vec<PathBuf> = Vec::new();
|
||||
@@ -31,13 +34,25 @@ pub fn simplify_dir_names<P: AsRef<Path>>(filenames: Vec<P>) -> HashSet<PathBuf>
|
||||
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], follow_links: bool) -> HashSet<u64> {
|
||||
use std::fs;
|
||||
// Gets the device ids for the filesystems which are used by the argument paths
|
||||
paths
|
||||
.into_iter()
|
||||
.filter_map(|p| match get_metadata(p, false) {
|
||||
Some((_size, Some((_id, dev)))) => Some(dev),
|
||||
_ => None,
|
||||
.iter()
|
||||
.filter_map(|p| {
|
||||
let follow_links = if follow_links {
|
||||
// slow path: If dereference-links is set, then we check if the file is a symbolic link
|
||||
match fs::symlink_metadata(p) {
|
||||
Ok(metadata) => metadata.file_type().is_symlink(),
|
||||
Err(_) => false,
|
||||
}
|
||||
} else {
|
||||
false
|
||||
};
|
||||
match get_metadata(p, false, follow_links) {
|
||||
Some((_size, Some((_id, dev)), _time)) => Some(dev),
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -62,6 +77,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<(Operator, i64)>,
|
||||
actual_time: i64,
|
||||
) -> bool {
|
||||
match filter_time {
|
||||
None => false,
|
||||
Some((Operator::Equal, bound_time)) => {
|
||||
!(actual_time >= *bound_time && actual_time < *bound_time + DAY_SECONDS)
|
||||
}
|
||||
Some((Operator::GreaterThan, bound_time)) => actual_time < *bound_time,
|
||||
Some((Operator::LessThan, bound_time)) => actual_time > *bound_time,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_filtered_out_due_to_invert_regex(filter_regex: &[Regex], dir: &Path) -> bool {
|
||||
filter_regex
|
||||
.iter()
|
||||
@@ -82,15 +111,15 @@ mod tests {
|
||||
fn test_simplify_dir() {
|
||||
let mut correct = HashSet::new();
|
||||
correct.insert(PathBuf::from("a"));
|
||||
assert_eq!(simplify_dir_names(vec!["a"]), correct);
|
||||
assert_eq!(simplify_dir_names(&["a"]), correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simplify_dir_rm_subdir() {
|
||||
let mut correct = HashSet::new();
|
||||
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(vec!["a/b", "a/b/c", "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(&["a/b", "a/b/c", "a/b/d/f"]), correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -99,7 +128,7 @@ mod tests {
|
||||
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
||||
correct.insert(PathBuf::from("c"));
|
||||
assert_eq!(
|
||||
simplify_dir_names(vec![
|
||||
simplify_dir_names(&[
|
||||
"a/b",
|
||||
"a/b//",
|
||||
"a/././b///",
|
||||
@@ -118,14 +147,14 @@ mod tests {
|
||||
correct.insert(PathBuf::from("b"));
|
||||
correct.insert(["c", "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]
|
||||
fn test_simplify_dir_dots() {
|
||||
let mut correct = HashSet::new();
|
||||
correct.insert(PathBuf::from("src"));
|
||||
assert_eq!(simplify_dir_names(vec!["src/."]), correct);
|
||||
assert_eq!(simplify_dir_names(&["src/."]), correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -133,7 +162,7 @@ mod tests {
|
||||
let mut correct = HashSet::new();
|
||||
correct.insert(PathBuf::from("src"));
|
||||
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]
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use assert_cmd::Command;
|
||||
use std::ffi::OsStr;
|
||||
use std::str;
|
||||
use std::process::Output;
|
||||
use std::sync::Once;
|
||||
use std::{io, str};
|
||||
|
||||
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.
|
||||
@@ -33,34 +35,59 @@ fn copy_test_data(dir: &str) {
|
||||
.map_err(|err| eprintln!("Error copying directory for test setup\n{:?}", err));
|
||||
}
|
||||
|
||||
fn create_unreadable_directory() -> io::Result<()> {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::fs;
|
||||
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() {
|
||||
INIT.call_once(|| {
|
||||
copy_test_data("tests/test_dir");
|
||||
copy_test_data("tests/test_dir2");
|
||||
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();
|
||||
|
||||
let mut a = &mut Command::cargo_bin("dust").unwrap();
|
||||
|
||||
let mut to_run = &mut Command::cargo_bin("dust").unwrap();
|
||||
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 {
|
||||
eprintln!(
|
||||
"output:\n{}\ndoes not contain any of:\n{}",
|
||||
output,
|
||||
valid_outputs.join("\n\n")
|
||||
"output(stdout):\n{}\ndoes not contain any of:\n{}",
|
||||
stdout_output,
|
||||
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
|
||||
@@ -68,20 +95,20 @@ fn exact_output_test<T: AsRef<OsStr>>(valid_outputs: Vec<String>, command_args:
|
||||
#[test]
|
||||
pub fn test_main_basic() {
|
||||
// -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)]
|
||||
#[test]
|
||||
pub fn test_main_multi_arg() {
|
||||
let command_args = vec![
|
||||
let command_args = [
|
||||
"-c",
|
||||
"-B",
|
||||
"/tmp/test_dir/many/",
|
||||
"/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> {
|
||||
@@ -111,8 +138,8 @@ fn main_output() -> Vec<String> {
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_main_long_paths() {
|
||||
let command_args = vec!["-c", "-p", "-B", "/tmp/test_dir/"];
|
||||
exact_output_test(main_output_long_paths(), command_args);
|
||||
let command_args = ["-c", "-p", "-B", "/tmp/test_dir/"];
|
||||
exact_stdout_test(&command_args, main_output_long_paths());
|
||||
}
|
||||
|
||||
fn main_output_long_paths() -> Vec<String> {
|
||||
@@ -139,8 +166,8 @@ fn main_output_long_paths() -> Vec<String> {
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_substring_of_names_and_long_names() {
|
||||
let command_args = vec!["-c", "-B", "/tmp/test_dir2"];
|
||||
exact_output_test(no_substring_of_names_output(), command_args);
|
||||
let command_args = ["-c", "-B", "/tmp/test_dir2"];
|
||||
exact_stdout_test(&command_args, no_substring_of_names_output());
|
||||
}
|
||||
|
||||
fn no_substring_of_names_output() -> Vec<String> {
|
||||
@@ -173,8 +200,8 @@ fn no_substring_of_names_output() -> Vec<String> {
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_unicode_directories() {
|
||||
let command_args = vec!["-c", "-B", "/tmp/test_dir_unicode"];
|
||||
exact_output_test(unicode_dir(), command_args);
|
||||
let command_args = ["-c", "-B", "/tmp/test_dir_unicode"];
|
||||
exact_stdout_test(&command_args, unicode_dir());
|
||||
}
|
||||
|
||||
fn unicode_dir() -> Vec<String> {
|
||||
@@ -200,8 +227,8 @@ fn unicode_dir() -> Vec<String> {
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_apparent_size() {
|
||||
let command_args = vec!["-c", "-s", "-b", "/tmp/test_dir"];
|
||||
exact_output_test(apparent_size_output(), command_args);
|
||||
let command_args = ["-c", "-s", "-b", "/tmp/test_dir"];
|
||||
exact_stdout_test(&command_args, apparent_size_output());
|
||||
}
|
||||
|
||||
fn apparent_size_output() -> Vec<String> {
|
||||
@@ -222,3 +249,26 @@ fn apparent_size_output() -> Vec<String> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,12 @@ pub fn test_d_flag_works() {
|
||||
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]
|
||||
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
|
||||
@@ -133,9 +139,9 @@ pub fn test_show_files_by_type() {
|
||||
#[cfg(target_family = "unix")]
|
||||
pub fn test_show_files_only() {
|
||||
let output = build_command(vec!["-c", "-F", "tests/test_dir"]);
|
||||
assert!(output.contains("tests/test_dir/many/a_file"));
|
||||
assert!(output.contains("tests/test_dir/many/hello_file"));
|
||||
assert!(!output.contains("tests/test_dir/many "));
|
||||
assert!(output.contains("a_file"));
|
||||
assert!(output.contains("hello_file"));
|
||||
assert!(!output.contains("many"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -232,3 +238,19 @@ pub fn test_show_files_by_invert_regex_match_multiple() {
|
||||
assert!(!output.contains("test_dir_unicode"));
|
||||
assert!(output.contains("many"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_no_color() {
|
||||
let output = build_command(vec!["-c"]);
|
||||
// Red is 31
|
||||
assert!(!output.contains("\x1B[31m"));
|
||||
assert!(!output.contains("\x1B[0m"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_force_color() {
|
||||
let output = build_command(vec!["-C"]);
|
||||
// Red is 31
|
||||
assert!(output.contains("\x1B[31m"));
|
||||
assert!(output.contains("\x1B[0m"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user