Compare commits

..

3 Commits

Author SHA1 Message Date
andy.boot 42b13da321 hack 2023-12-11 21:40:17 +00:00
andy.boot 11db301347 hack 2023-12-11 21:33:46 +00:00
andy.boot e52898186f ci: new release build
Add deb for aarch64-unknown-linux-musl
2023-11-23 22:35:24 +00:00
18 changed files with 293 additions and 480 deletions
+4 -4
View File
@@ -210,7 +210,7 @@ jobs:
echo set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS} echo set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS} echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
# * strip executable? # * strip executable?
STRIP="strip" ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;; aarch64-unknown-linux-musl) STRIP="" ;; armv7-unknown-linux-musleabi) STRIP="" ;; arm-unknown-linux-musleabi) STRIP="" ;; esac; STRIP="strip" ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;; aarch64-unknown-linux-musl) STRIP="aarch64-linux-gnueabihf-strip" ;; armv7-unknown-linux-musleabi) STRIP="" ;; arm-unknown-linux-musleabi) STRIP="" ;; esac;
echo set-output name=STRIP::${STRIP} echo set-output name=STRIP::${STRIP}
@@ -247,13 +247,13 @@ jobs:
with: with:
command: install command: install
args: cargo-deb args: cargo-deb
if: matrix.job.target == 'i686-unknown-linux-musl' || matrix.job.target == 'x86_64-unknown-linux-musl' if: matrix.job.target == 'i686-unknown-linux-musl' || matrix.job.target == 'x86_64-unknown-linux-musl' || matrix.job.target == 'aarch64-unknown-linux-musl'
- name: Build deb - name: Build deb
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: deb command: deb
args: --no-build --target=${{ matrix.job.target }} args: --no-build --target=${{ matrix.job.target }}
if: matrix.job.target == 'i686-unknown-linux-musl' || matrix.job.target == 'x86_64-unknown-linux-musl' if: matrix.job.target == 'i686-unknown-linux-musl' || matrix.job.target == 'x86_64-unknown-linux-musl' || matrix.job.target == 'aarch64-unknown-linux-musl'
- name: Test - name: Test
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
@@ -270,7 +270,7 @@ jobs:
with: with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}.deb name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}.deb
path: target/${{ matrix.job.target }}/debian path: target/${{ matrix.job.target }}/debian
if: matrix.job.target == 'i686-unknown-linux-musl' || matrix.job.target == 'x86_64-unknown-linux-musl' if: matrix.job.target == 'i686-unknown-linux-musl' || matrix.job.target == 'x86_64-unknown-linux-musl' || matrix.job.target == 'aarch64-unknown-linux-musl'
- name: Package - name: Package
shell: bash shell: bash
run: | run: |
Generated
+91 -91
View File
@@ -20,54 +20,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "anstream"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"utf8parse",
]
[[package]] [[package]]
name = "anstyle" name = "anstyle"
version = "1.0.4" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
[[package]]
name = "anstyle-parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628"
dependencies = [
"anstyle",
"windows-sys",
]
[[package]] [[package]]
name = "assert_cmd" name = "assert_cmd"
version = "2.0.12" version = "2.0.12"
@@ -83,6 +41,17 @@ dependencies = [
"wait-timeout", "wait-timeout",
] ]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi 0.1.19",
"libc",
"winapi",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.1.0" version = "1.1.0"
@@ -103,9 +72,9 @@ checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
[[package]] [[package]]
name = "bstr" name = "bstr"
version = "1.8.0" version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019"
dependencies = [ dependencies = [
"memchr", "memchr",
"regex-automata", "regex-automata",
@@ -120,56 +89,47 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.4.8" version = "3.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
dependencies = [ dependencies = [
"clap_builder", "atty",
] "bitflags 1.3.2",
[[package]]
name = "clap_builder"
version = "4.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc"
dependencies = [
"anstream",
"anstyle",
"clap_lex", "clap_lex",
"indexmap",
"strsim", "strsim",
"termcolor",
"textwrap",
] ]
[[package]] [[package]]
name = "clap_complete" name = "clap_complete"
version = "4.4.4" version = "3.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bffe91f06a11b4b9420f62103854e90867812cd5d01557f853c5ee8e791b12ae" checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8"
dependencies = [ dependencies = [
"clap", "clap",
] ]
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.6.0" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
dependencies = [
"os_str_bytes",
]
[[package]] [[package]]
name = "clap_mangen" name = "clap_mangen"
version = "0.2.15" version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3be86020147691e1d2ef58f75346a3d4d94807bfc473e377d52f09f0f7d77f7" checksum = "105180c05a72388d5f5e4e4f6c79eecb92497bda749fa8f963a16647c5d5377f"
dependencies = [ dependencies = [
"clap", "clap",
"roff", "roff",
] ]
[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]] [[package]]
name = "config-file" name = "config-file"
version = "0.2.3" version = "0.2.3"
@@ -254,7 +214,7 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]] [[package]]
name = "du-dust" name = "du-dust"
version = "0.9.0" version = "0.8.6"
dependencies = [ dependencies = [
"ansi_term", "ansi_term",
"assert_cmd", "assert_cmd",
@@ -284,9 +244,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.3.7" version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys", "windows-sys",
@@ -300,28 +260,53 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.11" version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"wasi", "wasi",
] ]
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.3.3" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]] [[package]]
name = "io-lifetimes" name = "io-lifetimes"
version = "1.0.11" version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi 0.3.3",
"libc", "libc",
"windows-sys", "windows-sys",
] ]
@@ -366,9 +351,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.4.11" version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f"
[[package]] [[package]]
name = "lscolors" name = "lscolors"
@@ -420,6 +405,12 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "os_str_bytes"
version = "6.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
[[package]] [[package]]
name = "overload" name = "overload"
version = "0.1.1" version = "0.1.1"
@@ -563,14 +554,14 @@ dependencies = [
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.38.25" version = "0.38.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"errno", "errno",
"libc", "libc",
"linux-raw-sys 0.4.11", "linux-raw-sys 0.4.10",
"windows-sys", "windows-sys",
] ]
@@ -582,18 +573,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.193" version = "1.0.191"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" checksum = "a834c4821019838224821468552240d4d95d14e751986442c816572d39a080c9"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.193" version = "1.0.191"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" checksum = "46fa52d5646bce91b680189fe5b1c049d2ea38dabb4e2e7c8d00ca12cfbfbcfd"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -651,10 +642,19 @@ dependencies = [
"cfg-if", "cfg-if",
"fastrand", "fastrand",
"redox_syscall", "redox_syscall",
"rustix 0.38.25", "rustix 0.38.21",
"windows-sys", "windows-sys",
] ]
[[package]]
name = "termcolor"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "terminal_size" name = "terminal_size"
version = "0.2.6" version = "0.2.6"
@@ -671,6 +671,12 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
[[package]]
name = "textwrap"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.50" version = "1.0.50"
@@ -718,12 +724,6 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "utf8parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]] [[package]]
name = "wait-timeout" name = "wait-timeout"
version = "0.2.0" version = "0.2.0"
+5 -5
View File
@@ -1,7 +1,7 @@
[package] [package]
name = "du-dust" name = "du-dust"
description = "A more intuitive version of du" description = "A more intuitive version of du"
version = "0.9.0" version = "0.8.6"
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"] authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
edition = "2021" edition = "2021"
readme = "README.md" readme = "README.md"
@@ -28,7 +28,7 @@ strip = true
[dependencies] [dependencies]
ansi_term = "0.12" ansi_term = "0.12"
clap = "4.4" clap = "3.2.17"
lscolors = "0.13" lscolors = "0.13"
terminal_size = "0.2" terminal_size = "0.2"
unicode-width = "0.1" unicode-width = "0.1"
@@ -49,9 +49,9 @@ assert_cmd = "2"
tempfile = "=3" tempfile = "=3"
[build-dependencies] [build-dependencies]
clap = "4.4" clap = "3.2.17"
clap_complete = "4.4" clap_complete = "3.2.4"
clap_mangen = "0.2" clap_mangen = "0.1"
[[test]] [[test]]
name = "integration" name = "integration"
+1 -2
View File
@@ -83,9 +83,8 @@ Usage: dust -v regex (Exclude files matching this regex (eg dust -v "\.png$" wou
Usage: dust -L (dereference-links - Treat sym links as directories and go into them) Usage: dust -L (dereference-links - Treat sym links as directories and go into them)
Usage: dust -P (Disable the progress indicator) 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 -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 --skip-total (No total row will be displayed)
Usage: dust -z 4000000 (Exclude output files/directories below size 4MB) Usage: dust -z 4000000 (Exclude files below size 4MB)
``` ```
## Config file ## Config file
+14 -22
View File
@@ -21,18 +21,18 @@ _dust() {
'--number-of-lines=[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]: : ' \ '*-X+[Exclude any file or directory with this name]: : ' \
'*--ignore-directory=[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]: : ' \ '-z+[Minimum size file to include in output]: : ' \
'--min-size=[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)*-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\$" ]: : ' \ '(-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)*-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\$" ]: : ' \ '(-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]: : ' \ '-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]: : ' \ '--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)]: : ' \ '-h[Print help information]' \
'--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)]: : ' \ '--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-p[Subdirectories will not have their path shortened]' \ '-p[Subdirectories will not have their path shortened]' \
'--full-paths[Subdirectories will not have their path shortened]' \ '--full-paths[Subdirectories will not have their path shortened]' \
'-L[dereference sym links - Treat sym links as directories and go into them]' \ '-L[dereference sym links - Treat sym links as directories and go into them]' \
@@ -43,14 +43,14 @@ _dust() {
'--apparent-size[Use file length instead of blocks]' \ '--apparent-size[Use file length instead of blocks]' \
'-r[Print tree upside down (biggest highest)]' \ '-r[Print tree upside down (biggest highest)]' \
'--reverse[Print tree upside down (biggest highest)]' \ '--reverse[Print tree upside down (biggest highest)]' \
'-c[No colors will be printed (Useful for commands like\: watch)]' \ '-c[No colors will be printed (Useful for commands like: watch)]' \
'--no-colors[No colors will be printed (Useful for commands like\: watch)]' \ '--no-colors[No colors will be printed (Useful for commands like: watch)]' \
'-b[No percent bars or percentages will be displayed]' \ '-b[No percent bars or percentages will be displayed]' \
'--no-percent-bars[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]' \ '-B[percent bars moved to right side of screen]' \
'--bars-on-right[percent bars moved to right side of screen]' \ '--bars-on-right[percent bars moved to right side of screen]' \
'-R[For screen readers. Removes bars. Adds new column\: depth level (May want to use -p too for full path)]' \ '-R[For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)]' \
'--screen-reader[For screen readers. Removes bars. Adds new column\: depth level (May want to use -p too for full path)]' \ '--screen-reader[For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)]' \
'--skip-total[No total row will be displayed]' \ '--skip-total[No total row will be displayed]' \
'-f[Directory '\''size'\'' is number of child files instead of disk size]' \ '-f[Directory '\''size'\'' is number of child files instead of disk size]' \
'--filecount[Directory '\''size'\'' is number of child files instead of disk size]' \ '--filecount[Directory '\''size'\'' is number of child files instead of disk size]' \
@@ -66,11 +66,7 @@ _dust() {
'(-F --only-file -t --file_types)--only-dir[Only directories will be displayed.]' \ '(-F --only-file -t --file_types)--only-dir[Only directories will be displayed.]' \
'(-D --only-dir)-F[Only files will be displayed. (Finds your largest files)]' \ '(-D --only-dir)-F[Only files will be displayed. (Finds your largest files)]' \
'(-D --only-dir)--only-file[Only files will be displayed. (Finds your largest files)]' \ '(-D --only-dir)--only-file[Only files will be displayed. (Finds your largest files)]' \
'-h[Print help]' \ '*::inputs:' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::params:' \
&& ret=0 && ret=0
} }
@@ -80,8 +76,4 @@ _dust_commands() {
_describe -t commands 'dust commands' commands "$@" _describe -t commands 'dust commands' commands "$@"
} }
if [ "$funcstack[1]" = "_dust" ]; then _dust "$@"
_dust "$@"
else
compdef _dust dust
fi
+12 -16
View File
@@ -25,10 +25,8 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
[CompletionResult]::new('--depth', 'depth', [CompletionResultType]::ParameterName, 'Depth to show') [CompletionResult]::new('--depth', 'depth', [CompletionResultType]::ParameterName, 'Depth to show')
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)') [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
[CompletionResult]::new('--number-of-lines', 'number-of-lines', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)') [CompletionResult]::new('--number-of-lines', 'number-of-lines', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
[CompletionResult]::new('-X', 'X ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this name') [CompletionResult]::new('-X', 'X', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this name')
[CompletionResult]::new('--ignore-directory', 'ignore-directory', [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('-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') [CompletionResult]::new('-z', 'z', [CompletionResultType]::ParameterName, 'Minimum size file to include in output')
[CompletionResult]::new('--min-size', 'min-size', [CompletionResultType]::ParameterName, 'Minimum size file to include in output') [CompletionResult]::new('--min-size', 'min-size', [CompletionResultType]::ParameterName, 'Minimum size file to include in output')
[CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Exclude filepaths matching this regex. To ignore png files type: -v "\.png$" ') [CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Exclude filepaths matching this regex. To ignore png files type: -v "\.png$" ')
@@ -37,11 +35,13 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
[CompletionResult]::new('--filter', 'filter', [CompletionResultType]::ParameterName, 'Only include filepaths matching this regex. For png files type: -e "\.png$" ') [CompletionResult]::new('--filter', 'filter', [CompletionResultType]::ParameterName, 'Only include filepaths matching this regex. For png files type: -e "\.png$" ')
[CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width') [CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width')
[CompletionResult]::new('--terminal_width', 'terminal_width', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width') [CompletionResult]::new('--terminal_width', 'terminal_width', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width')
[CompletionResult]::new('-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('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
[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('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened') [CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
[CompletionResult]::new('--full-paths', 'full-paths', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened') [CompletionResult]::new('--full-paths', 'full-paths', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
[CompletionResult]::new('-L', 'L ', [CompletionResultType]::ParameterName, 'dereference sym links - Treat sym links as directories and go into them') [CompletionResult]::new('-L', 'L', [CompletionResultType]::ParameterName, 'dereference sym links - Treat sym links as directories and go into them')
[CompletionResult]::new('--dereference-links', 'dereference-links', [CompletionResultType]::ParameterName, 'dereference sym links - Treat sym links as directories and go into them') [CompletionResult]::new('--dereference-links', 'dereference-links', [CompletionResultType]::ParameterName, 'dereference sym links - Treat sym links as directories and go into them')
[CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'Only count the files and directories on the same filesystem as the supplied directory') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'Only count the files and directories on the same filesystem as the supplied directory')
[CompletionResult]::new('--limit-filesystem', 'limit-filesystem', [CompletionResultType]::ParameterName, 'Only count the files and directories on the same filesystem as the supplied directory') [CompletionResult]::new('--limit-filesystem', 'limit-filesystem', [CompletionResultType]::ParameterName, 'Only count the files and directories on the same filesystem as the supplied directory')
@@ -53,9 +53,9 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
[CompletionResult]::new('--no-colors', 'no-colors', [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('-b', 'b', [CompletionResultType]::ParameterName, 'No percent bars or percentages will be displayed') [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('--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') [CompletionResult]::new('-B', 'B', [CompletionResultType]::ParameterName, 'percent bars moved to right side of screen')
[CompletionResult]::new('--bars-on-right', 'bars-on-right', [CompletionResultType]::ParameterName, 'percent bars moved to right side of screen') [CompletionResult]::new('--bars-on-right', 'bars-on-right', [CompletionResultType]::ParameterName, 'percent bars moved to right side of screen')
[CompletionResult]::new('-R', 'R ', [CompletionResultType]::ParameterName, 'For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)') [CompletionResult]::new('-R', 'R', [CompletionResultType]::ParameterName, 'For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)')
[CompletionResult]::new('--screen-reader', 'screen-reader', [CompletionResultType]::ParameterName, 'For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)') [CompletionResult]::new('--screen-reader', 'screen-reader', [CompletionResultType]::ParameterName, 'For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)')
[CompletionResult]::new('--skip-total', 'skip-total', [CompletionResultType]::ParameterName, 'No total row will be displayed') [CompletionResult]::new('--skip-total', 'skip-total', [CompletionResultType]::ParameterName, 'No total row will be displayed')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Directory ''size'' is number of child files instead of disk size') [CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Directory ''size'' is number of child files instead of disk size')
@@ -64,18 +64,14 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
[CompletionResult]::new('--ignore_hidden', 'ignore_hidden', [CompletionResultType]::ParameterName, 'Do not display hidden files') [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('-t', 't', [CompletionResultType]::ParameterName, 'show only these file types')
[CompletionResult]::new('--file_types', 'file_types', [CompletionResultType]::ParameterName, 'show only these file types') [CompletionResult]::new('--file_types', 'file_types', [CompletionResultType]::ParameterName, 'show only these file types')
[CompletionResult]::new('-H', 'H ', [CompletionResultType]::ParameterName, 'print sizes in powers of 1000 (e.g., 1.1G)') [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('--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('-P', 'P', [CompletionResultType]::ParameterName, 'Disable the progress indication.')
[CompletionResult]::new('--no-progress', 'no-progress', [CompletionResultType]::ParameterName, 'Disable the progress indication.') [CompletionResult]::new('--no-progress', 'no-progress', [CompletionResultType]::ParameterName, 'Disable the progress indication.')
[CompletionResult]::new('-D', 'D ', [CompletionResultType]::ParameterName, 'Only directories will be displayed.') [CompletionResult]::new('-D', 'D', [CompletionResultType]::ParameterName, 'Only directories will be displayed.')
[CompletionResult]::new('--only-dir', 'only-dir', [CompletionResultType]::ParameterName, 'Only directories will be displayed.') [CompletionResult]::new('--only-dir', 'only-dir', [CompletionResultType]::ParameterName, 'Only directories will be displayed.')
[CompletionResult]::new('-F', 'F ', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)') [CompletionResult]::new('-F', 'F', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)')
[CompletionResult]::new('--only-file', 'only-file', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)') [CompletionResult]::new('--only-file', 'only-file', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
break break
} }
}) })
+5 -21
View File
@@ -1,5 +1,5 @@
_dust() { _dust() {
local i cur prev opts cmd local i cur prev opts cmds
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
@@ -8,8 +8,8 @@ _dust() {
for i in ${COMP_WORDS[@]} for i in ${COMP_WORDS[@]}
do do
case "${cmd},${i}" in case "${i}" in
",$1") "$1")
cmd="dust" cmd="dust"
;; ;;
*) *)
@@ -19,7 +19,7 @@ _dust() {
case "${cmd}" in case "${cmd}" in
dust) 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="-h -V -d -n -p -X -L -x -s -r -c -b -B -z -R -f -i -v -e -t -w -H -P -D -F --help --version --depth --number-of-lines --full-paths --ignore-directory --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 <inputs>..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0 return 0
@@ -49,14 +49,6 @@ _dust() {
COMPREPLY=($(compgen -f "${cur}")) COMPREPLY=($(compgen -f "${cur}"))
return 0 return 0
;; ;;
--ignore-all-in-file)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-I)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--min-size) --min-size)
COMPREPLY=($(compgen -f "${cur}")) COMPREPLY=($(compgen -f "${cur}"))
return 0 return 0
@@ -89,14 +81,6 @@ _dust() {
COMPREPLY=($(compgen -f "${cur}")) COMPREPLY=($(compgen -f "${cur}"))
return 0 return 0
;; ;;
--stack-size)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-S)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;
@@ -107,4 +91,4 @@ _dust() {
esac esac
} }
complete -F _dust -o nosort -o bashdefault -o default dust complete -F _dust -o bashdefault -o default dust
+4 -8
View File
@@ -24,8 +24,6 @@ set edit:completion:arg-completer[dust] = {|@words|
cand --number-of-lines 'Number of lines of output to show. (Default is terminal_height - 10)' cand --number-of-lines 'Number of lines of output to show. (Default is terminal_height - 10)'
cand -X 'Exclude any file or directory with this name' cand -X 'Exclude any file or directory with this name'
cand --ignore-directory 'Exclude any file or directory with this name' cand --ignore-directory 'Exclude any file or directory with this name'
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' cand -z 'Minimum size file to include in output'
cand --min-size 'Minimum size file to include in output' cand --min-size 'Minimum size file to include in output'
cand -v 'Exclude filepaths matching this regex. To ignore png files type: -v "\.png$" ' cand -v 'Exclude filepaths matching this regex. To ignore png files type: -v "\.png$" '
@@ -34,8 +32,10 @@ set edit:completion:arg-completer[dust] = {|@words|
cand --filter 'Only include filepaths matching this regex. For png files type: -e "\.png$" ' cand --filter 'Only include filepaths matching this regex. For png files type: -e "\.png$" '
cand -w 'Specify width of output overriding the auto detection of terminal width' cand -w 'Specify width of output overriding the auto detection of terminal width'
cand --terminal_width 'Specify width of output overriding the auto detection of terminal width' cand --terminal_width 'Specify width of output overriding the auto detection of terminal width'
cand -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 -h 'Print help information'
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 --help 'Print help information'
cand -V 'Print version information'
cand --version 'Print version information'
cand -p 'Subdirectories will not have their path shortened' cand -p 'Subdirectories will not have their path shortened'
cand --full-paths 'Subdirectories will not have their path shortened' cand --full-paths 'Subdirectories will not have their path shortened'
cand -L 'dereference sym links - Treat sym links as directories and go into them' cand -L 'dereference sym links - Treat sym links as directories and go into them'
@@ -69,10 +69,6 @@ set edit:completion:arg-completer[dust] = {|@words|
cand --only-dir 'Only directories will be displayed.' cand --only-dir 'Only directories will be displayed.'
cand -F 'Only files will be displayed. (Finds your largest files)' cand -F 'Only files will be displayed. (Finds your largest files)'
cand --only-file 'Only files will be displayed. (Finds your largest files)' cand --only-file 'Only files will be displayed. (Finds your largest files)'
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
} }
] ]
$completions[$command] $completions[$command]
+2 -4
View File
@@ -1,12 +1,12 @@
complete -c dust -s d -l depth -d 'Depth to show' -r complete -c dust -s d -l depth -d 'Depth to show' -r
complete -c dust -s n -l number-of-lines -d 'Number of lines of output to show. (Default is terminal_height - 10)' -r complete -c dust -s n -l number-of-lines -d 'Number of lines of output to show. (Default is terminal_height - 10)' -r
complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this name' -r complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this name' -r
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 z -l min-size -d 'Minimum size file to include in output' -r complete -c dust -s z -l min-size -d 'Minimum size file to include in output' -r
complete -c dust -s v -l invert-filter -d 'Exclude filepaths matching this regex. To ignore png files type: -v "\\.png$" ' -r complete -c dust -s v -l invert-filter -d 'Exclude filepaths matching this regex. To ignore png files type: -v "\\.png$" ' -r
complete -c dust -s e -l filter -d 'Only include filepaths matching this regex. For png files type: -e "\\.png$" ' -r complete -c dust -s e -l filter -d 'Only include filepaths matching this regex. For png files type: -e "\\.png$" ' -r
complete -c dust -s w -l terminal_width -d 'Specify width of output overriding the auto detection of terminal width' -r complete -c dust -s w -l terminal_width -d 'Specify width of output overriding the auto detection of terminal width' -r
complete -c dust -s 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 h -l help -d 'Print help information'
complete -c dust -s V -l version -d 'Print version information'
complete -c dust -s p -l full-paths -d 'Subdirectories will not have their path shortened' complete -c dust -s p -l full-paths -d 'Subdirectories will not have their path shortened'
complete -c dust -s L -l dereference-links -d 'dereference sym links - Treat sym links as directories and go into them' complete -c dust -s L -l dereference-links -d 'dereference sym links - Treat sym links as directories and go into them'
complete -c dust -s x -l limit-filesystem -d 'Only count the files and directories on the same filesystem as the supplied directory' complete -c dust -s x -l limit-filesystem -d 'Only count the files and directories on the same filesystem as the supplied directory'
@@ -24,5 +24,3 @@ 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 -s P -l no-progress -d 'Disable the progress indication.'
complete -c dust -s D -l only-dir -d 'Only directories will be displayed.' complete -c dust -s D -l only-dir -d 'Only directories will be displayed.'
complete -c dust -s F -l only-file -d 'Only files will be displayed. (Finds your largest files)' complete -c dust -s F -l only-file -d 'Only files will be displayed. (Finds your largest files)'
complete -c dust -s h -l help -d 'Print help'
complete -c dust -s V -l version -d 'Print version'
+10 -16
View File
@@ -1,14 +1,20 @@
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.TH Dust 1 "Dust 0.9.0" .TH Dust 1 "Dust 0.8.6"
.SH NAME .SH NAME
Dust \- Like du but more intuitive Dust \- Like du but more intuitive
.SH SYNOPSIS .SH SYNOPSIS
\fBDust\fR [\fB\-d\fR|\fB\-\-depth\fR] [\fB\-n\fR|\fB\-\-number\-of\-lines\fR] [\fB\-p\fR|\fB\-\-full\-paths\fR] [\fB\-X\fR|\fB\-\-ignore\-directory\fR] [\fB\-I\fR|\fB\-\-ignore\-all\-in\-file\fR] [\fB\-L\fR|\fB\-\-dereference\-links\fR] [\fB\-x\fR|\fB\-\-limit\-filesystem\fR] [\fB\-s\fR|\fB\-\-apparent\-size\fR] [\fB\-r\fR|\fB\-\-reverse\fR] [\fB\-c\fR|\fB\-\-no\-colors\fR] [\fB\-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\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\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\-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] [\fIinputs\fR]
.SH DESCRIPTION .SH DESCRIPTION
Like du but more intuitive Like du but more intuitive
.SH OPTIONS .SH OPTIONS
.TP .TP
\fB\-h\fR, \fB\-\-help\fR
Print help information
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version information
.TP
\fB\-d\fR, \fB\-\-depth\fR \fB\-d\fR, \fB\-\-depth\fR
Depth to show Depth to show
.TP .TP
@@ -21,9 +27,6 @@ Subdirectories will not have their path shortened
\fB\-X\fR, \fB\-\-ignore\-directory\fR \fB\-X\fR, \fB\-\-ignore\-directory\fR
Exclude any file or directory with this name Exclude any file or directory with this name
.TP .TP
\fB\-I\fR, \fB\-\-ignore\-all\-in\-file\fR
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 \fB\-L\fR, \fB\-\-dereference\-links\fR
dereference sym links \- Treat sym links as directories and go into them dereference sym links \- Treat sym links as directories and go into them
.TP .TP
@@ -84,16 +87,7 @@ Only directories will be displayed.
\fB\-F\fR, \fB\-\-only\-file\fR \fB\-F\fR, \fB\-\-only\-file\fR
Only files will be displayed. (Finds your largest files) Only files will be displayed. (Finds your largest files)
.TP .TP
\fB\-S\fR, \fB\-\-stack\-size\fR [\fIinputs\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\-h\fR, \fB\-\-help\fR
Print help
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version
.TP
[\fIparams\fR]
.SH VERSION .SH VERSION
v0.9.0 v0.8.6
+18 -46
View File
@@ -1,9 +1,9 @@
use clap::{value_parser, Arg, Command}; use clap::{Arg, Command};
// For single thread mode set this variable on your command line: // For single thread mode set this variable on your command line:
// export RAYON_NUM_THREADS=1 // export RAYON_NUM_THREADS=1
pub fn build_cli() -> Command { pub fn build_cli() -> Command<'static> {
Command::new("Dust") Command::new("Dust")
.about("Like du but more intuitive") .about("Like du but more intuitive")
.version(env!("CARGO_PKG_VERSION")) .version(env!("CARGO_PKG_VERSION"))
@@ -12,127 +12,111 @@ pub fn build_cli() -> Command {
Arg::new("depth") Arg::new("depth")
.short('d') .short('d')
.long("depth") .long("depth")
.value_parser(value_parser!(usize))
.help("Depth to show") .help("Depth to show")
.num_args(1) .takes_value(true)
) )
.arg( .arg(
Arg::new("number_of_lines") Arg::new("number_of_lines")
.short('n') .short('n')
.long("number-of-lines") .long("number-of-lines")
.value_parser(value_parser!(usize))
.help("Number of lines of output to show. (Default is terminal_height - 10)") .help("Number of lines of output to show. (Default is terminal_height - 10)")
.num_args(1) .takes_value(true)
) )
.arg( .arg(
Arg::new("display_full_paths") Arg::new("display_full_paths")
.short('p') .short('p')
.long("full-paths") .long("full-paths")
.action(clap::ArgAction::SetTrue)
.help("Subdirectories will not have their path shortened"), .help("Subdirectories will not have their path shortened"),
) )
.arg( .arg(
Arg::new("ignore_directory") Arg::new("ignore_directory")
.short('X') .short('X')
.long("ignore-directory") .long("ignore-directory")
.action(clap::ArgAction::Append) .takes_value(true)
.number_of_values(1)
.multiple_occurrences(true)
.help("Exclude any file or directory with this name"), .help("Exclude any file or directory with this name"),
)
.arg(
Arg::new("ignore_all_in_file")
.short('I')
.long("ignore-all-in-file")
.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"),
) )
.arg( .arg(
Arg::new("dereference_links") Arg::new("dereference_links")
.short('L') .short('L')
.long("dereference-links") .long("dereference-links")
.action(clap::ArgAction::SetTrue)
.help("dereference sym links - Treat sym links as directories and go into them"), .help("dereference sym links - Treat sym links as directories and go into them"),
) )
.arg( .arg(
Arg::new("limit_filesystem") Arg::new("limit_filesystem")
.short('x') .short('x')
.long("limit-filesystem") .long("limit-filesystem")
.action(clap::ArgAction::SetTrue)
.help("Only count the files and directories on the same filesystem as the supplied directory"), .help("Only count the files and directories on the same filesystem as the supplied directory"),
) )
.arg( .arg(
Arg::new("display_apparent_size") Arg::new("display_apparent_size")
.short('s') .short('s')
.long("apparent-size") .long("apparent-size")
.action(clap::ArgAction::SetTrue)
.help("Use file length instead of blocks"), .help("Use file length instead of blocks"),
) )
.arg( .arg(
Arg::new("reverse") Arg::new("reverse")
.short('r') .short('r')
.long("reverse") .long("reverse")
.action(clap::ArgAction::SetTrue)
.help("Print tree upside down (biggest highest)"), .help("Print tree upside down (biggest highest)"),
) )
.arg( .arg(
Arg::new("no_colors") Arg::new("no_colors")
.short('c') .short('c')
.long("no-colors") .long("no-colors")
.action(clap::ArgAction::SetTrue)
.help("No colors will be printed (Useful for commands like: watch)"), .help("No colors will be printed (Useful for commands like: watch)"),
) )
.arg( .arg(
Arg::new("no_bars") Arg::new("no_bars")
.short('b') .short('b')
.long("no-percent-bars") .long("no-percent-bars")
.action(clap::ArgAction::SetTrue)
.help("No percent bars or percentages will be displayed"), .help("No percent bars or percentages will be displayed"),
) )
.arg( .arg(
Arg::new("bars_on_right") Arg::new("bars_on_right")
.short('B') .short('B')
.long("bars-on-right") .long("bars-on-right")
.action(clap::ArgAction::SetTrue)
.help("percent bars moved to right side of screen"), .help("percent bars moved to right side of screen"),
) )
.arg( .arg(
Arg::new("min_size") Arg::new("min_size")
.short('z') .short('z')
.long("min-size") .long("min-size")
.num_args(1) .takes_value(true)
.number_of_values(1)
.help("Minimum size file to include in output"), .help("Minimum size file to include in output"),
) )
.arg( .arg(
Arg::new("screen_reader") Arg::new("screen_reader")
.short('R') .short('R')
.long("screen-reader") .long("screen-reader")
.action(clap::ArgAction::SetTrue)
.help("For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)"), .help("For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)"),
) )
.arg( .arg(
Arg::new("skip_total") Arg::new("skip_total")
.long("skip-total") .long("skip-total")
.action(clap::ArgAction::SetTrue)
.help("No total row will be displayed"), .help("No total row will be displayed"),
) )
.arg( .arg(
Arg::new("by_filecount") Arg::new("by_filecount")
.short('f') .short('f')
.long("filecount") .long("filecount")
.action(clap::ArgAction::SetTrue)
.help("Directory 'size' is number of child files instead of disk size"), .help("Directory 'size' is number of child files instead of disk size"),
) )
.arg( .arg(
Arg::new("ignore_hidden") Arg::new("ignore_hidden")
.short('i') // Do not use 'h' this is used by 'help' .short('i') // Do not use 'h' this is used by 'help'
.long("ignore_hidden") .long("ignore_hidden")
.action(clap::ArgAction::SetTrue)
.help("Do not display hidden files"), .help("Do not display hidden files"),
) )
.arg( .arg(
Arg::new("invert_filter") Arg::new("invert_filter")
.short('v') .short('v')
.long("invert-filter") .long("invert-filter")
.action(clap::ArgAction::Append) .takes_value(true)
.number_of_values(1)
.multiple_occurrences(true)
.conflicts_with("filter") .conflicts_with("filter")
.conflicts_with("types") .conflicts_with("types")
.help("Exclude filepaths matching this regex. To ignore png files type: -v \"\\.png$\" "), .help("Exclude filepaths matching this regex. To ignore png files type: -v \"\\.png$\" "),
@@ -141,7 +125,9 @@ pub fn build_cli() -> Command {
Arg::new("filter") Arg::new("filter")
.short('e') .short('e')
.long("filter") .long("filter")
.action(clap::ArgAction::Append) .takes_value(true)
.number_of_values(1)
.multiple_occurrences(true)
.conflicts_with("types") .conflicts_with("types")
.help("Only include filepaths matching this regex. For png files type: -e \"\\.png$\" "), .help("Only include filepaths matching this regex. For png files type: -e \"\\.png$\" "),
) )
@@ -151,29 +137,26 @@ pub fn build_cli() -> Command {
.long("file_types") .long("file_types")
.conflicts_with("depth") .conflicts_with("depth")
.conflicts_with("only_dir") .conflicts_with("only_dir")
.action(clap::ArgAction::SetTrue)
.help("show only these file types"), .help("show only these file types"),
) )
.arg( .arg(
Arg::new("width") Arg::new("width")
.short('w') .short('w')
.long("terminal_width") .long("terminal_width")
.num_args(1) .takes_value(true)
.value_parser(value_parser!(usize)) .number_of_values(1)
.help("Specify width of output overriding the auto detection of terminal width"), .help("Specify width of output overriding the auto detection of terminal width"),
) )
.arg( .arg(
Arg::new("iso") Arg::new("iso")
.short('H') .short('H')
.long("si") .long("si")
.action(clap::ArgAction::SetTrue)
.help("print sizes in powers of 1000 (e.g., 1.1G)") .help("print sizes in powers of 1000 (e.g., 1.1G)")
) )
.arg( .arg(
Arg::new("disable_progress") Arg::new("disable_progress")
.short('P') .short('P')
.long("no-progress") .long("no-progress")
.action(clap::ArgAction::SetTrue)
.help("Disable the progress indication."), .help("Disable the progress indication."),
) )
.arg( .arg(
@@ -182,7 +165,6 @@ pub fn build_cli() -> Command {
.long("only-dir") .long("only-dir")
.conflicts_with("only_file") .conflicts_with("only_file")
.conflicts_with("types") .conflicts_with("types")
.action(clap::ArgAction::SetTrue)
.help("Only directories will be displayed."), .help("Only directories will be displayed."),
) )
.arg( .arg(
@@ -190,17 +172,7 @@ pub fn build_cli() -> Command {
.short('F') .short('F')
.long("only-file") .long("only-file")
.conflicts_with("only_dir") .conflicts_with("only_dir")
.action(clap::ArgAction::SetTrue)
.help("Only files will be displayed. (Finds your largest files)"), .help("Only files will be displayed. (Finds your largest files)"),
) )
.arg( .arg(Arg::new("inputs").multiple_occurrences(true))
Arg::new("stack_size")
.short('S')
.long("stack-size")
.num_args(1)
.value_parser(value_parser!(usize))
.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)))
} }
+24 -35
View File
@@ -26,57 +26,58 @@ pub struct Config {
pub disable_progress: Option<bool>, pub disable_progress: Option<bool>,
pub depth: Option<usize>, pub depth: Option<usize>,
pub bars_on_right: Option<bool>, pub bars_on_right: Option<bool>,
pub stack_size: Option<usize>,
} }
impl Config { impl Config {
pub fn get_no_colors(&self, options: &ArgMatches) -> bool { pub fn get_no_colors(&self, options: &ArgMatches) -> bool {
Some(true) == self.no_colors || options.get_flag("no_colors") Some(true) == self.no_colors || options.is_present("no_colors")
} }
pub fn get_disable_progress(&self, options: &ArgMatches) -> bool { pub fn get_disable_progress(&self, options: &ArgMatches) -> bool {
Some(true) == self.disable_progress Some(true) == self.disable_progress
|| options.get_flag("disable_progress") || options.is_present("disable_progress")
|| !std::io::stdout().is_terminal() || !std::io::stdout().is_terminal()
} }
pub fn get_apparent_size(&self, options: &ArgMatches) -> bool { pub fn get_apparent_size(&self, options: &ArgMatches) -> bool {
Some(true) == self.display_apparent_size || options.get_flag("display_apparent_size") Some(true) == self.display_apparent_size || options.is_present("display_apparent_size")
} }
pub fn get_ignore_hidden(&self, options: &ArgMatches) -> bool { pub fn get_ignore_hidden(&self, options: &ArgMatches) -> bool {
Some(true) == self.ignore_hidden || options.get_flag("ignore_hidden") Some(true) == self.ignore_hidden || options.is_present("ignore_hidden")
} }
pub fn get_full_paths(&self, options: &ArgMatches) -> bool { pub fn get_full_paths(&self, options: &ArgMatches) -> bool {
// If we are only showing files, always show full paths // If we are only showing files, always show full paths
Some(true) == self.display_full_paths Some(true) == self.display_full_paths
|| options.get_flag("display_full_paths") || options.is_present("display_full_paths")
|| self.get_only_file(options) || self.get_only_file(options)
} }
pub fn get_reverse(&self, options: &ArgMatches) -> bool { pub fn get_reverse(&self, options: &ArgMatches) -> bool {
Some(true) == self.reverse || options.get_flag("reverse") Some(true) == self.reverse || options.is_present("reverse")
} }
pub fn get_no_bars(&self, options: &ArgMatches) -> bool { pub fn get_no_bars(&self, options: &ArgMatches) -> bool {
Some(true) == self.no_bars || options.get_flag("no_bars") Some(true) == self.no_bars || options.is_present("no_bars")
} }
pub fn get_iso(&self, options: &ArgMatches) -> bool { pub fn get_iso(&self, options: &ArgMatches) -> bool {
Some(true) == self.iso || options.get_flag("iso") Some(true) == self.iso || options.is_present("iso")
} }
pub fn get_skip_total(&self, options: &ArgMatches) -> bool { pub fn get_skip_total(&self, options: &ArgMatches) -> bool {
Some(true) == self.skip_total || options.get_flag("skip_total") Some(true) == self.skip_total || options.is_present("skip_total")
} }
pub fn get_screen_reader(&self, options: &ArgMatches) -> bool { pub fn get_screen_reader(&self, options: &ArgMatches) -> bool {
Some(true) == self.screen_reader || options.get_flag("screen_reader") Some(true) == self.screen_reader || options.is_present("screen_reader")
} }
pub fn get_depth(&self, options: &ArgMatches) -> usize { pub fn get_depth(&self, options: &ArgMatches) -> usize {
if let Some(v) = options.get_one::<usize>("depth") { if let Some(v) = options.value_of("depth") {
return *v; if let Ok(v) = v.parse::<usize>() {
return v;
}
} }
self.depth.unwrap_or(usize::MAX) 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, iso: bool) -> Option<usize> {
let size_from_param = options.get_one::<String>("min_size"); let size_from_param = options.value_of("min_size");
self._get_min_size(size_from_param, iso) self._get_min_size(size_from_param, iso)
} }
fn _get_min_size(&self, min_size: Option<&String>, iso: bool) -> Option<usize> { fn _get_min_size(&self, min_size: Option<&str>, iso: bool) -> Option<usize> {
let size_from_param = min_size.and_then(|a| convert_min_size(a, iso)); let size_from_param = min_size.and_then(|a| convert_min_size(a, iso));
if size_from_param.is_none() { if size_from_param.is_none() {
@@ -88,21 +89,13 @@ impl Config {
} }
} }
pub fn get_only_dir(&self, options: &ArgMatches) -> bool { pub fn get_only_dir(&self, options: &ArgMatches) -> bool {
Some(true) == self.only_dir || options.get_flag("only_dir") Some(true) == self.only_dir || options.is_present("only_dir")
} }
pub fn get_only_file(&self, options: &ArgMatches) -> bool { pub fn get_only_file(&self, options: &ArgMatches) -> bool {
Some(true) == self.only_file || options.get_flag("only_file") Some(true) == self.only_file || options.is_present("only_file")
} }
pub fn get_bars_on_right(&self, options: &ArgMatches) -> bool { pub fn get_bars_on_right(&self, options: &ArgMatches) -> bool {
Some(true) == self.bars_on_right || options.get_flag("bars_on_right") Some(true) == self.bars_on_right || options.is_present("bars_on_right")
}
pub fn get_custom_stack_size(&self, options: &ArgMatches) -> Option<usize> {
let from_cmd_line = options.get_one::<usize>("stack_size");
if from_cmd_line.is_none() {
self.stack_size
} else {
from_cmd_line.copied()
}
} }
} }
@@ -165,7 +158,7 @@ pub fn get_config() -> Config {
mod tests { mod tests {
#[allow(unused_imports)] #[allow(unused_imports)]
use super::*; use super::*;
use clap::{value_parser, Arg, ArgMatches, Command}; use clap::{Arg, ArgMatches, Command};
#[test] #[test]
fn test_conversion() { fn test_conversion() {
@@ -185,10 +178,10 @@ mod tests {
..Default::default() ..Default::default()
}; };
assert_eq!(c._get_min_size(None, false), Some(1024)); 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(Some("2K"), false), Some(2048));
assert_eq!(c._get_min_size(None, true), Some(1000)); 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("2K"), true), Some(2000));
} }
#[test] #[test]
@@ -222,12 +215,8 @@ mod tests {
fn get_args(args: Vec<&str>) -> ArgMatches { fn get_args(args: Vec<&str>) -> ArgMatches {
Command::new("Dust") Command::new("Dust")
.arg( .trailing_var_arg(true)
Arg::new("depth") .arg(Arg::new("depth").long("depth").takes_value(true))
.long("depth")
.num_args(1)
.value_parser(value_parser!(usize)),
)
.get_matches_from(args) .get_matches_from(args)
} }
} }
+44 -75
View File
@@ -1,11 +1,9 @@
use std::fs; use std::fs;
use std::sync::Arc; use std::sync::Arc;
use std::sync::Mutex;
use crate::node::Node; use crate::node::Node;
use crate::progress::Operation; use crate::progress::Operation;
use crate::progress::PAtomicInfo; use crate::progress::PAtomicInfo;
use crate::progress::RuntimeErrors;
use crate::progress::ORDERING; use crate::progress::ORDERING;
use crate::utils::is_filtered_out_due_to_invert_regex; use crate::utils::is_filtered_out_due_to_invert_regex;
use crate::utils::is_filtered_out_due_to_regex; use crate::utils::is_filtered_out_due_to_regex;
@@ -30,17 +28,16 @@ pub struct WalkData<'a> {
pub ignore_hidden: bool, pub ignore_hidden: bool,
pub follow_links: bool, pub follow_links: bool,
pub progress_data: Arc<PAtomicInfo>, pub progress_data: Arc<PAtomicInfo>,
pub errors: Arc<Mutex<RuntimeErrors>>,
} }
pub fn walk_it(dirs: HashSet<PathBuf>, walk_data: &WalkData) -> Vec<Node> { pub fn walk_it(dirs: HashSet<PathBuf>, walk_data: WalkData) -> Vec<Node> {
let mut inodes = HashSet::new(); let mut inodes = HashSet::new();
let top_level_nodes: Vec<_> = dirs let top_level_nodes: Vec<_> = dirs
.into_iter() .into_iter()
.filter_map(|d| { .filter_map(|d| {
let prog_data = &walk_data.progress_data; let prog_data = &walk_data.progress_data;
prog_data.clear_state(&d); prog_data.clear_state(&d);
let node = walk(d, walk_data, 0)?; let node = walk(d, &walk_data, 0)?;
prog_data.state.store(Operation::PREPARING, ORDERING); prog_data.state.store(Operation::PREPARING, ORDERING);
@@ -129,83 +126,55 @@ fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> { fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
let prog_data = &walk_data.progress_data; let prog_data = &walk_data.progress_data;
let errors = &walk_data.errors; let mut children = vec![];
let children = if dir.is_dir() { if let Ok(entries) = fs::read_dir(&dir) {
let read_dir = fs::read_dir(&dir); children = entries
match read_dir { .into_iter()
Ok(entries) => { .par_bridge()
entries .filter_map(|entry| {
.into_iter() if let Ok(ref entry) = entry {
.par_bridge() // uncommenting the below line gives simpler code but
.filter_map(|entry| { // rayon doesn't parallelize as well giving a 3X performance drop
if let Ok(ref entry) = entry { // hence we unravel the recursion a bit
// 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 !ignore_file(entry, walk_data) {
if let Ok(data) = entry.file_type() { if let Ok(data) = entry.file_type() {
if data.is_dir() if data.is_dir() || (walk_data.follow_links && data.is_symlink()) {
|| (walk_data.follow_links && data.is_symlink()) return walk(entry.path(), walk_data, depth + 1);
{
return walk(entry.path(), walk_data, depth + 1);
}
let node = build_node(
entry.path(),
vec![],
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(); let node = build_node(
editable_error.no_permissions = true 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;
} }
None
})
.collect()
}
Err(failed) => {
let mut editable_error = errors.lock().unwrap();
match failed.kind() {
std::io::ErrorKind::PermissionDenied => {
editable_error.no_permissions = true;
}
std::io::ErrorKind::NotFound => {
editable_error.file_not_found.insert(failed.to_string());
}
_ => {
editable_error.unknown_error.insert(failed.to_string());
} }
} else {
prog_data.no_permissions.store(true, ORDERING)
} }
vec![] None
} })
} .collect();
} else { } else if !dir.is_file() {
if !dir.is_file() { walk_data.progress_data.no_permissions.store(true, ORDERING)
let mut editable_error = errors.lock().unwrap(); }
let bad_file = dir.as_os_str().to_string_lossy().into();
editable_error.file_not_found.insert(bad_file);
}
vec![]
};
build_node( build_node(
dir, dir,
children, children,
+54 -110
View File
@@ -11,26 +11,23 @@ mod progress;
mod utils; mod utils;
use crate::cli::build_cli; use crate::cli::build_cli;
use crate::progress::RuntimeErrors;
use clap::parser::ValuesRef;
use dir_walker::WalkData; use dir_walker::WalkData;
use display::InitialDisplayData; use display::InitialDisplayData;
use filter::AggregateData; use filter::AggregateData;
use progress::PIndicator; use progress::PIndicator;
use regex::Error; use progress::ORDERING;
use std::collections::HashSet; use std::collections::HashSet;
use std::fs::read_to_string;
use std::panic; use std::panic;
use std::process; use std::process;
use std::sync::Arc;
use std::sync::Mutex;
use sysinfo::{System, SystemExt}; use sysinfo::{System, SystemExt};
use self::display::draw_it; use self::display::draw_it;
use clap::Values;
use config::get_config; use config::get_config;
use dir_walker::walk_it; use dir_walker::walk_it;
use filter::get_biggest; use filter::get_biggest;
use filter_type::get_all_file_types; use filter_type::get_all_file_types;
use rayon::ThreadPoolBuildError;
use regex::Regex; use regex::Regex;
use std::cmp::max; use std::cmp::max;
use std::path::PathBuf; use std::path::PathBuf;
@@ -89,7 +86,7 @@ fn get_width_of_terminal() -> usize {
.unwrap_or(DEFAULT_TERMINAL_WIDTH) .unwrap_or(DEFAULT_TERMINAL_WIDTH)
} }
fn get_regex_value(maybe_value: Option<ValuesRef<String>>) -> Vec<Regex> { fn get_regex_value(maybe_value: Option<Values>) -> Vec<Regex> {
maybe_value maybe_value
.unwrap_or_default() .unwrap_or_default()
.map(|reg| { .map(|reg| {
@@ -105,68 +102,49 @@ fn main() {
let options = build_cli().get_matches(); let options = build_cli().get_matches();
let config = get_config(); let config = get_config();
let target_dirs = match options.get_many::<String>("params") { let target_dirs = match options.values_of("inputs") {
Some(values) => values.map(|v| v.as_str()).collect::<Vec<&str>>(), Some(values) => values.collect(),
None => vec!["."], None => vec!["."],
}; };
let summarize_file_types = options.get_flag("types"); let summarize_file_types = options.is_present("types");
let filter_regexs = get_regex_value(options.get_many("filter")); let filter_regexs = get_regex_value(options.values_of("filter"));
let invert_filter_regexs = get_regex_value(options.get_many("invert_filter")); let invert_filter_regexs = get_regex_value(options.values_of("invert_filter"));
let terminal_width: usize = match options.get_one::<usize>("width") { let terminal_width = options
Some(&val) => val, .value_of_t("width")
None => get_width_of_terminal(), .unwrap_or_else(|_| get_width_of_terminal());
};
let depth = config.get_depth(&options); let depth = config.get_depth(&options);
// If depth is set, then we set the default number_of_lines to be max // If depth is set, then we set the default number_of_lines to be max
// instead of screen height // instead of screen height
let default_height = if depth != usize::MAX {
let number_of_lines = match options.get_one::<usize>("number_of_lines") { usize::MAX
Some(&val) => val, } else {
None => { get_height_of_terminal()
if depth != usize::MAX {
usize::MAX
} else {
get_height_of_terminal()
}
}
}; };
let number_of_lines = options
.value_of("number_of_lines")
.and_then(|v| {
v.parse()
.map_err(|_| eprintln!("Ignoring bad value for number_of_lines"))
.ok()
})
.unwrap_or(default_height);
let no_colors = init_color(config.get_no_colors(&options)); let no_colors = init_color(config.get_no_colors(&options));
let ignore_directories = match options.get_many::<String>("ignore_directory") { let ignore_directories = options
Some(values) => values .values_of("ignore_directory")
.map(|v| v.as_str()) .unwrap_or_default()
.map(PathBuf::from) .map(PathBuf::from);
.collect::<Vec<PathBuf>>(),
None => vec![],
};
let ignore_from_file_result = match options.get_one::<String>("ignore_all_in_file") { let by_filecount = options.is_present("by_filecount");
Some(val) => read_to_string(val) let limit_filesystem = options.is_present("limit_filesystem");
.unwrap() let follow_links = options.is_present("dereference_links");
.lines()
.map(Regex::new)
.collect::<Vec<Result<Regex, Error>>>(),
None => vec![],
};
let ignore_from_file = ignore_from_file_result
.into_iter()
.filter_map(|x| x.ok())
.collect::<Vec<Regex>>();
let invert_filter_regexs = invert_filter_regexs
.into_iter()
.chain(ignore_from_file)
.collect::<Vec<Regex>>();
let by_filecount = options.get_flag("by_filecount");
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 simplified_dirs = simplify_dir_names(target_dirs);
let allowed_filesystems = limit_filesystem let allowed_filesystems = limit_filesystem
@@ -174,7 +152,6 @@ fn main() {
.unwrap_or_default(); .unwrap_or_default();
let ignored_full_path: HashSet<PathBuf> = ignore_directories let ignored_full_path: HashSet<PathBuf> = ignore_directories
.into_iter()
.flat_map(|x| simplified_dirs.iter().map(move |d| d.join(&x))) .flat_map(|x| simplified_dirs.iter().map(move |d| d.join(&x)))
.collect(); .collect();
@@ -197,12 +174,14 @@ fn main() {
ignore_hidden, ignore_hidden,
follow_links, follow_links,
progress_data: indicator.data.clone(), progress_data: indicator.data.clone(),
errors: Arc::new(Mutex::new(RuntimeErrors::default())),
}; };
let stack_size = config.get_custom_stack_size(&options);
init_rayon(&stack_size);
let top_level_nodes = walk_it(simplified_dirs, &walk_data); let result = panic::catch_unwind(|| init_rayon);
if result.is_err() {
eprintln!("Problem initializing rayon, try: export RAYON_NUM_THREADS=1")
}
let top_level_nodes = walk_it(simplified_dirs, walk_data);
let tree = match summarize_file_types { 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),
@@ -213,38 +192,19 @@ fn main() {
only_file: config.get_only_file(&options), only_file: config.get_only_file(&options),
number_of_lines, number_of_lines,
depth, depth,
using_a_filter: !filter_regexs.is_empty() || !invert_filter_regexs.is_empty(), using_a_filter: options.values_of("filter").is_some()
|| options.value_of("invert_filter").is_some(),
}; };
get_biggest(top_level_nodes, agg_data) get_biggest(top_level_nodes, agg_data)
} }
}; };
// Must have stopped indicator before we print to stderr let failed_permissions = indicator.data.no_permissions.load(ORDERING);
indicator.stop(); indicator.stop();
// Must have stopped indicator before we print to stderr
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
.iter()
.map(|a| a.as_ref())
.collect::<Vec<&str>>()
.join(", ");
eprintln!("No such file or directory: {}", err);
}
if failed_permissions { if failed_permissions {
eprintln!("Did not have permissions for all directories"); eprintln!("Did not have permissions for all directories");
} }
if !final_errors.unknown_error.is_empty() {
let err = final_errors
.unknown_error
.iter()
.map(|a| a.as_ref())
.collect::<Vec<&str>>()
.join(", ");
eprintln!("Unknown Error: {}", err);
}
if let Some(root_node) = tree { if let Some(root_node) = tree {
let idd = InitialDisplayData { let idd = InitialDisplayData {
@@ -266,34 +226,18 @@ fn main() {
} }
} }
fn init_rayon(stack_size: &Option<usize>) { fn init_rayon() -> Result<(), ThreadPoolBuildError> {
// Rayon seems to raise this error on 32-bit builds let large_stack = usize::pow(1024, 3);
// The global thread pool has not been initialized.: ThreadPoolBuildError { kind: GlobalPoolAlreadyInitialized } let mut s = System::new();
if cfg!(target_pointer_width = "64") { s.refresh_memory();
let result = panic::catch_unwind(|| { let available = s.available_memory();
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() { if available > large_stack.try_into().unwrap() {
// Larger stack size to handle cases with lots of nested directories // Larger stack size to handle cases with lots of nested directories
rayon::ThreadPoolBuilder::new() rayon::ThreadPoolBuilder::new()
.stack_size(large_stack) .stack_size(large_stack)
.build_global() .build_global()
} else { } else {
rayon::ThreadPoolBuilder::new().build_global() rayon::ThreadPoolBuilder::new().build_global()
}
}
}
});
if result.is_err() {
eprintln!("Problem initializing rayon, try: export RAYON_NUM_THREADS=1")
}
} }
} }
+2 -9
View File
@@ -1,9 +1,8 @@
use std::{ use std::{
collections::HashSet,
io::Write, io::Write,
path::Path, path::Path,
sync::{ sync::{
atomic::{AtomicU64, AtomicU8, AtomicUsize, Ordering}, atomic::{AtomicBool, AtomicU64, AtomicU8, AtomicUsize, Ordering},
mpsc::{self, RecvTimeoutError, Sender}, mpsc::{self, RecvTimeoutError, Sender},
Arc, RwLock, Arc, RwLock,
}, },
@@ -56,6 +55,7 @@ pub struct PAtomicInfo {
pub total_file_size: AtomicU64, pub total_file_size: AtomicU64,
pub state: AtomicU8, pub state: AtomicU8,
pub current_path: ThreadStringWrapper, pub current_path: ThreadStringWrapper,
pub no_permissions: AtomicBool,
} }
impl PAtomicInfo { impl PAtomicInfo {
@@ -68,13 +68,6 @@ impl PAtomicInfo {
} }
} }
#[derive(Default)]
pub struct RuntimeErrors {
pub no_permissions: bool,
pub file_not_found: HashSet<String>,
pub unknown_error: HashSet<String>,
}
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
fn format_preparing_str(prog_char: char, data: &PAtomicInfo, is_iso: bool) -> String { fn format_preparing_str(prog_char: char, data: &PAtomicInfo, is_iso: bool) -> String {
+1 -2
View File
@@ -1,2 +1 @@
something hi
.secret
+2 -14
View File
@@ -64,7 +64,6 @@ pub fn test_d_flag_works_and_still_recurses_down() {
// We had a bug where running with '-d 1' would stop at the first directory and the code // We had a bug where running with '-d 1' would stop at the first directory and the code
// would fail to recurse down // would fail to recurse down
let output = build_command(vec!["-d", "1", "-f", "-c", "tests/test_dir2/"]); let output = build_command(vec!["-d", "1", "-f", "-c", "tests/test_dir2/"]);
assert!(output.contains("1 ┌── dir"));
assert!(output.contains("4 ┌─┴ test_dir2")); assert!(output.contains("4 ┌─┴ test_dir2"));
} }
@@ -74,25 +73,14 @@ pub fn test_ignore_dir() {
let output = build_command(vec!["-c", "-X", "dir_substring", "tests/test_dir2/"]); let output = build_command(vec!["-c", "-X", "dir_substring", "tests/test_dir2/"]);
assert!(!output.contains("dir_substring")); assert!(!output.contains("dir_substring"));
} }
// Add test for multiple dirs - with -d 0 and maybe -d 1 check the
#[test]
pub fn test_ignore_all_in_file() {
let output = build_command(vec![
"-c",
"-I",
"tests/test_dir_hidden_entries/.hidden_file",
"tests/test_dir_hidden_entries/",
]);
assert!(output.contains(" test_dir_hidden_entries"));
assert!(!output.contains(".secret"));
}
#[test] #[test]
pub fn test_with_bad_param() { pub fn test_with_bad_param() {
let mut cmd = Command::cargo_bin("dust").unwrap(); let mut cmd = Command::cargo_bin("dust").unwrap();
let result = cmd.arg("bad_place").unwrap(); let result = cmd.arg("bad_place").unwrap();
let stderr = str::from_utf8(&result.stderr).unwrap(); let stderr = str::from_utf8(&result.stderr).unwrap();
assert!(stderr.contains("No such file or directory")); assert!(stderr.contains("Did not have permissions for all directories"));
} }
#[test] #[test]