mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Compare commits
28 Commits
v0.8.5
...
cargo_update2
| Author | SHA1 | Date | |
|---|---|---|---|
| 88797b3f66 | |||
| 13af2ff351 | |||
| b5e3f4ca2f | |||
| 7ee744207b | |||
| 96068518f6 | |||
| 10168e0a47 | |||
| 6768df9a7b | |||
| e80892a9e7 | |||
| cd53fc7494 | |||
| e8c7990a17 | |||
| c8b61d2f46 | |||
| 6e0505bfd7 | |||
| 24bdbf036e | |||
| 29085686e1 | |||
| 8b1632dde8 | |||
| f3275cd59c | |||
| 939ed89ebb | |||
| a58e5f48f6 | |||
| 3f9014d8c7 | |||
| 7c54d41ace | |||
| 2fa14ca19c | |||
| 211d89e634 | |||
| 0038cb24b4 | |||
| 658f8d2e2b | |||
| 2c23336794 | |||
| a4ae013459 | |||
| c259d3b566 | |||
| bdfd3c01a5 |
@@ -96,6 +96,11 @@ jobs:
|
|||||||
target: arm-unknown-linux-gnueabihf,
|
target: arm-unknown-linux-gnueabihf,
|
||||||
use-cross: use-cross,
|
use-cross: use-cross,
|
||||||
}
|
}
|
||||||
|
- {
|
||||||
|
os: ubuntu-latest,
|
||||||
|
target: arm-unknown-linux-musleabi,
|
||||||
|
use-cross: use-cross,
|
||||||
|
}
|
||||||
- {
|
- {
|
||||||
os: ubuntu-latest,
|
os: ubuntu-latest,
|
||||||
target: i686-unknown-linux-gnu,
|
target: i686-unknown-linux-gnu,
|
||||||
@@ -205,7 +210,9 @@ 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="" ;;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="" ;; armv7-unknown-linux-musleabi) STRIP="" ;; arm-unknown-linux-musleabi) STRIP="" ;; esac;
|
||||||
|
|
||||||
|
|
||||||
echo set-output name=STRIP::${STRIP}
|
echo set-output name=STRIP::${STRIP}
|
||||||
echo ::set-output name=STRIP::${STRIP}
|
echo ::set-output name=STRIP::${STRIP}
|
||||||
- name: Create all needed build/work directories
|
- name: Create all needed build/work directories
|
||||||
|
|||||||
Generated
+329
-314
File diff suppressed because it is too large
Load Diff
+9
-6
@@ -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.8.5"
|
version = "0.9.0"
|
||||||
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
|
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@@ -28,8 +28,7 @@ strip = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ansi_term = "0.12"
|
ansi_term = "0.12"
|
||||||
atty = "0.2.14"
|
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"
|
||||||
@@ -50,14 +49,18 @@ assert_cmd = "2"
|
|||||||
tempfile = "=3"
|
tempfile = "=3"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
clap = "3.2.17"
|
clap = "4.4"
|
||||||
clap_complete = "3.2.4"
|
clap_complete = "4.4"
|
||||||
clap_mangen = "0.1"
|
clap_mangen = "0.2"
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "integration"
|
name = "integration"
|
||||||
path = "tests/tests.rs"
|
path = "tests/tests.rs"
|
||||||
|
|
||||||
|
[package.metadata.binstall]
|
||||||
|
pkg-url = "{ repo }/releases/download/v{ version }/dust-v{ version }-{ target }{ archive-suffix }"
|
||||||
|
bin-dir = "dust-v{ version }-{ target }/{ bin }{ binary-ext }"
|
||||||
|
|
||||||
[package.metadata.deb]
|
[package.metadata.deb]
|
||||||
section = "utils"
|
section = "utils"
|
||||||
assets = [
|
assets = [
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
[](https://travis-ci.org/bootandy/dust)
|
[](https://github.com/bootandy/dust/actions)
|
||||||
|
|
||||||
|
|
||||||
# Dust
|
# Dust
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ Because I want an easy way to see where my disk is being used.
|
|||||||
|
|
||||||
#### Windows:
|
#### Windows:
|
||||||
|
|
||||||
|
- `scoop install dust`
|
||||||
- Windows GNU version - works
|
- Windows GNU version - works
|
||||||
- Windows MSVC - requires: [VCRUNTIME140.dll](https://docs.microsoft.com/en-gb/cpp/windows/latest-supported-vc-redist?view=msvc-170)
|
- Windows MSVC - requires: [VCRUNTIME140.dll](https://docs.microsoft.com/en-gb/cpp/windows/latest-supported-vc-redist?view=msvc-170)
|
||||||
|
|
||||||
@@ -70,6 +72,7 @@ Usage: dust -H (si print sizes in powers of 1000 instead of 1024)
|
|||||||
Usage: dust -X ignore (ignore all files and directories with the name 'ignore')
|
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 -x (Only show directories on the same filesystem)
|
||||||
Usage: dust -b (Do not show percentages or draw ASCII bars)
|
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 -i (Do not show hidden files)
|
Usage: dust -i (Do not show hidden files)
|
||||||
Usage: dust -c (No colors [monochrome])
|
Usage: dust -c (No colors [monochrome])
|
||||||
Usage: dust -f (Count files instead of diskspace)
|
Usage: dust -f (Count files instead of diskspace)
|
||||||
@@ -80,9 +83,18 @@ 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 files below size 4MB)
|
Usage: dust -z 4000000 (Exclude output files/directories below size 4MB)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Config file
|
||||||
|
|
||||||
|
Dust has a config file where the above options can be set.
|
||||||
|
Either: `~/.config/dust/config.toml` or `~/.dust.toml`
|
||||||
|
```
|
||||||
|
$ cat ~/.config/dust/config.toml
|
||||||
|
reverse=true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Alternatives
|
## Alternatives
|
||||||
|
|||||||
+26
-16
@@ -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]: : ' \
|
||||||
'-h[Print help information]' \
|
'-S+[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]' \
|
'--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)]: : ' \
|
||||||
'-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,15 +43,17 @@ _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]' \
|
||||||
'-R[For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)]' \
|
'-B[percent bars moved to right side of screen]' \
|
||||||
'--screen-reader[For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)]' \
|
'--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)]' \
|
||||||
|
'--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/dirs not disk size]' \
|
'-f[Directory '\''size'\'' is number of child files instead of disk size]' \
|
||||||
'--filecount[Directory '\''size'\'' is number of child files/dirs not disk size]' \
|
'--filecount[Directory '\''size'\'' is number of child files instead of disk size]' \
|
||||||
'-i[Do not display hidden files]' \
|
'-i[Do not display hidden files]' \
|
||||||
'--ignore_hidden[Do not display hidden files]' \
|
'--ignore_hidden[Do not display hidden files]' \
|
||||||
'(-d --depth -D --only-dir)-t[show only these file types]' \
|
'(-d --depth -D --only-dir)-t[show only these file types]' \
|
||||||
@@ -64,7 +66,11 @@ _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)]' \
|
||||||
'*::inputs:' \
|
'-h[Print help]' \
|
||||||
|
'--help[Print help]' \
|
||||||
|
'-V[Print version]' \
|
||||||
|
'--version[Print version]' \
|
||||||
|
'*::params:_files' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,4 +80,8 @@ _dust_commands() {
|
|||||||
_describe -t commands 'dust commands' commands "$@"
|
_describe -t commands 'dust commands' commands "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_dust "$@"
|
if [ "$funcstack[1]" = "_dust" ]; then
|
||||||
|
_dust "$@"
|
||||||
|
else
|
||||||
|
compdef _dust dust
|
||||||
|
fi
|
||||||
|
|||||||
+19
-13
@@ -25,8 +25,10 @@ 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$" ')
|
||||||
@@ -35,13 +37,11 @@ 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('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
|
[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('--help', 'help', [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('-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,23 +53,29 @@ 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('-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('-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('-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/dirs not disk size')
|
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Directory ''size'' is number of child files instead of disk size')
|
||||||
[CompletionResult]::new('--filecount', 'filecount', [CompletionResultType]::ParameterName, 'Directory ''size'' is number of child files/dirs not disk size')
|
[CompletionResult]::new('--filecount', 'filecount', [CompletionResultType]::ParameterName, 'Directory ''size'' is number of child files instead of disk size')
|
||||||
[CompletionResult]::new('-i', 'i', [CompletionResultType]::ParameterName, 'Do not display hidden files')
|
[CompletionResult]::new('-i', 'i', [CompletionResultType]::ParameterName, 'Do not display hidden files')
|
||||||
[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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
+29
-6
@@ -1,5 +1,5 @@
|
|||||||
_dust() {
|
_dust() {
|
||||||
local i cur prev opts cmds
|
local i cur prev opts cmd
|
||||||
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 "${i}" in
|
case "${cmd},${i}" in
|
||||||
"$1")
|
",$1")
|
||||||
cmd="dust"
|
cmd="dust"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -19,10 +19,13 @@ _dust() {
|
|||||||
|
|
||||||
case "${cmd}" in
|
case "${cmd}" in
|
||||||
dust)
|
dust)
|
||||||
opts="-h -V -d -n -p -X -L -x -s -r -c -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 --min-size --screen-reader --skip-total --filecount --ignore_hidden --invert-filter --filter --file_types --terminal_width --si --no-progress --only-dir --only-file <inputs>..."
|
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]..."
|
||||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
if [[ ${cur} == -* ]] ; then
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||||
return 0
|
return 0
|
||||||
|
elif [[ ${cur} == * ]] ; then
|
||||||
|
_filedir
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
--depth)
|
--depth)
|
||||||
@@ -49,6 +52,14 @@ _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
|
||||||
@@ -81,6 +92,14 @@ _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=()
|
||||||
;;
|
;;
|
||||||
@@ -91,4 +110,8 @@ _dust() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
complete -F _dust -o bashdefault -o default dust
|
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
|
||||||
|
complete -F _dust -o nosort -o bashdefault -o default dust
|
||||||
|
else
|
||||||
|
complete -F _dust -o bashdefault -o default dust
|
||||||
|
fi
|
||||||
|
|||||||
+12
-6
@@ -24,6 +24,8 @@ 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$" '
|
||||||
@@ -32,10 +34,8 @@ 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 -h 'Print help information'
|
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 --help '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 -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'
|
||||||
@@ -50,11 +50,13 @@ set edit:completion:arg-completer[dust] = {|@words|
|
|||||||
cand --no-colors 'No colors will be printed (Useful for commands like: watch)'
|
cand --no-colors 'No colors will be printed (Useful for commands like: watch)'
|
||||||
cand -b 'No percent bars or percentages will be displayed'
|
cand -b 'No percent bars or percentages will be displayed'
|
||||||
cand --no-percent-bars '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'
|
||||||
|
cand --bars-on-right 'percent bars moved to right side of screen'
|
||||||
cand -R 'For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)'
|
cand -R 'For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)'
|
||||||
cand --screen-reader 'For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)'
|
cand --screen-reader 'For screen readers. Removes bars. Adds new column: depth level (May want to use -p too for full path)'
|
||||||
cand --skip-total 'No total row will be displayed'
|
cand --skip-total 'No total row will be displayed'
|
||||||
cand -f 'Directory ''size'' is number of child files/dirs not disk size'
|
cand -f 'Directory ''size'' is number of child files instead of disk size'
|
||||||
cand --filecount 'Directory ''size'' is number of child files/dirs not disk size'
|
cand --filecount 'Directory ''size'' is number of child files instead of disk size'
|
||||||
cand -i 'Do not display hidden files'
|
cand -i 'Do not display hidden files'
|
||||||
cand --ignore_hidden 'Do not display hidden files'
|
cand --ignore_hidden 'Do not display hidden files'
|
||||||
cand -t 'show only these file types'
|
cand -t 'show only these file types'
|
||||||
@@ -67,6 +69,10 @@ 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]
|
||||||
|
|||||||
@@ -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 h -l help -d 'Print help information'
|
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 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'
|
||||||
@@ -14,12 +14,15 @@ 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 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 no-colors -d 'No colors will be printed (Useful for commands like: watch)'
|
||||||
complete -c dust -s b -l no-percent-bars -d 'No percent bars or percentages will be displayed'
|
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)'
|
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)'
|
||||||
complete -c dust -l skip-total -d 'No total row will be displayed'
|
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/dirs not disk size'
|
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 i -l ignore_hidden -d 'Do not display hidden files'
|
||||||
complete -c dust -s t -l file_types -d 'show only these file types'
|
complete -c dust -s t -l file_types -d 'show only these file types'
|
||||||
complete -c dust -s H -l si -d 'print sizes in powers of 1000 (e.g., 1.1G)'
|
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'
|
||||||
|
|||||||
+20
-11
@@ -1,20 +1,14 @@
|
|||||||
.ie \n(.g .ds Aq \(aq
|
.ie \n(.g .ds Aq \(aq
|
||||||
.el .ds Aq '
|
.el .ds Aq '
|
||||||
.TH Dust 1 "Dust 0.8.5"
|
.TH Dust 1 "Dust 0.9.0"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Dust \- Like du but more intuitive
|
Dust \- Like du but more intuitive
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
\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\-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]
|
\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]
|
||||||
.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
|
||||||
@@ -27,6 +21,9 @@ 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
|
||||||
@@ -45,6 +42,9 @@ No colors will be printed (Useful for commands like: watch)
|
|||||||
\fB\-b\fR, \fB\-\-no\-percent\-bars\fR
|
\fB\-b\fR, \fB\-\-no\-percent\-bars\fR
|
||||||
No percent bars or percentages will be displayed
|
No percent bars or percentages will be displayed
|
||||||
.TP
|
.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
|
||||||
Minimum size file to include in output
|
Minimum size file to include in output
|
||||||
.TP
|
.TP
|
||||||
@@ -55,7 +55,7 @@ For screen readers. Removes bars. Adds new column: depth level (May want to use
|
|||||||
No total row will be displayed
|
No total row will be displayed
|
||||||
.TP
|
.TP
|
||||||
\fB\-f\fR, \fB\-\-filecount\fR
|
\fB\-f\fR, \fB\-\-filecount\fR
|
||||||
Directory \*(Aqsize\*(Aq is number of child files/dirs not disk size
|
Directory \*(Aqsize\*(Aq is number of child files instead of disk size
|
||||||
.TP
|
.TP
|
||||||
\fB\-i\fR, \fB\-\-ignore_hidden\fR
|
\fB\-i\fR, \fB\-\-ignore_hidden\fR
|
||||||
Do not display hidden files
|
Do not display hidden files
|
||||||
@@ -84,7 +84,16 @@ 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
|
||||||
[\fIinputs\fR]
|
\fB\-S\fR, \fB\-\-stack\-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\-h\fR, \fB\-\-help\fR
|
||||||
|
Print help
|
||||||
|
.TP
|
||||||
|
\fB\-V\fR, \fB\-\-version\fR
|
||||||
|
Print version
|
||||||
|
.TP
|
||||||
|
[\fIparams\fR]
|
||||||
|
|
||||||
.SH VERSION
|
.SH VERSION
|
||||||
v0.8.5
|
v0.9.0
|
||||||
|
|||||||
+53
-19
@@ -1,9 +1,9 @@
|
|||||||
use clap::{Arg, Command};
|
use clap::{value_parser, Arg, Command};
|
||||||
|
|
||||||
// For single thread mode set this variable on your command line:
|
// For single thread mode set this variable on your command line:
|
||||||
// export RAYON_NUM_THREADS=1
|
// export RAYON_NUM_THREADS=1
|
||||||
|
|
||||||
pub fn build_cli() -> Command<'static> {
|
pub fn build_cli() -> Command {
|
||||||
Command::new("Dust")
|
Command::new("Dust")
|
||||||
.about("Like du but more intuitive")
|
.about("Like du but more intuitive")
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
.version(env!("CARGO_PKG_VERSION"))
|
||||||
@@ -12,105 +12,127 @@ pub fn build_cli() -> Command<'static> {
|
|||||||
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")
|
||||||
.takes_value(true)
|
.num_args(1)
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("number_of_lines")
|
Arg::new("number_of_lines")
|
||||||
.short('n')
|
.short('n')
|
||||||
.long("number-of-lines")
|
.long("number-of-lines")
|
||||||
|
.value_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)")
|
||||||
.takes_value(true)
|
.num_args(1)
|
||||||
)
|
)
|
||||||
.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")
|
||||||
.takes_value(true)
|
.action(clap::ArgAction::Append)
|
||||||
.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::new("bars_on_right")
|
||||||
|
.short('B')
|
||||||
|
.long("bars-on-right")
|
||||||
|
.action(clap::ArgAction::SetTrue)
|
||||||
|
.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")
|
||||||
.takes_value(true)
|
.num_args(1)
|
||||||
.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")
|
||||||
.help("Directory 'size' is number of child files/dirs not disk size"),
|
.action(clap::ArgAction::SetTrue)
|
||||||
|
.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")
|
||||||
.takes_value(true)
|
.action(clap::ArgAction::Append)
|
||||||
.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$\" "),
|
||||||
@@ -119,9 +141,7 @@ pub fn build_cli() -> Command<'static> {
|
|||||||
Arg::new("filter")
|
Arg::new("filter")
|
||||||
.short('e')
|
.short('e')
|
||||||
.long("filter")
|
.long("filter")
|
||||||
.takes_value(true)
|
.action(clap::ArgAction::Append)
|
||||||
.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$\" "),
|
||||||
)
|
)
|
||||||
@@ -131,26 +151,29 @@ pub fn build_cli() -> Command<'static> {
|
|||||||
.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")
|
||||||
.takes_value(true)
|
.num_args(1)
|
||||||
.number_of_values(1)
|
.value_parser(value_parser!(usize))
|
||||||
.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(
|
||||||
@@ -159,6 +182,7 @@ pub fn build_cli() -> Command<'static> {
|
|||||||
.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(
|
||||||
@@ -166,7 +190,17 @@ pub fn build_cli() -> Command<'static> {
|
|||||||
.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::new("inputs").multiple_occurrences(true))
|
.arg(
|
||||||
|
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)))
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-23
@@ -1,6 +1,7 @@
|
|||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use config_file::FromConfigFile;
|
use config_file::FromConfigFile;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use std::io::IsTerminal;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
@@ -24,56 +25,58 @@ pub struct Config {
|
|||||||
pub only_file: Option<bool>,
|
pub only_file: Option<bool>,
|
||||||
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 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.is_present("no_colors")
|
Some(true) == self.no_colors || options.get_flag("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 || options.is_present("disable_progress")
|
Some(true) == self.disable_progress
|
||||||
|
|| options.get_flag("disable_progress")
|
||||||
|
|| !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.is_present("display_apparent_size")
|
Some(true) == self.display_apparent_size || options.get_flag("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.is_present("ignore_hidden")
|
Some(true) == self.ignore_hidden || options.get_flag("ignore_hidden")
|
||||||
}
|
}
|
||||||
pub fn get_full_paths(&self, options: &ArgMatches) -> bool {
|
pub fn get_full_paths(&self, options: &ArgMatches) -> bool {
|
||||||
// If we are only showing files, always show full paths
|
// If we are only showing files, always show full paths
|
||||||
Some(true) == self.display_full_paths
|
Some(true) == self.display_full_paths
|
||||||
|| options.is_present("display_full_paths")
|
|| options.get_flag("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.is_present("reverse")
|
Some(true) == self.reverse || options.get_flag("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.is_present("no_bars")
|
Some(true) == self.no_bars || options.get_flag("no_bars")
|
||||||
}
|
}
|
||||||
pub fn get_iso(&self, options: &ArgMatches) -> bool {
|
pub fn get_iso(&self, options: &ArgMatches) -> bool {
|
||||||
Some(true) == self.iso || options.is_present("iso")
|
Some(true) == self.iso || options.get_flag("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.is_present("skip_total")
|
Some(true) == self.skip_total || options.get_flag("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.is_present("screen_reader")
|
Some(true) == self.screen_reader || options.get_flag("screen_reader")
|
||||||
}
|
}
|
||||||
pub fn get_depth(&self, options: &ArgMatches) -> usize {
|
pub fn get_depth(&self, options: &ArgMatches) -> usize {
|
||||||
if let Some(v) = options.value_of("depth") {
|
if let Some(v) = options.get_one::<usize>("depth") {
|
||||||
if let Ok(v) = v.parse::<usize>() {
|
return *v;
|
||||||
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.value_of("min_size");
|
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, iso)
|
||||||
}
|
}
|
||||||
fn _get_min_size(&self, min_size: Option<&str>, iso: bool) -> Option<usize> {
|
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));
|
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() {
|
||||||
@@ -85,10 +88,21 @@ 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.is_present("only_dir")
|
Some(true) == self.only_dir || options.get_flag("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.is_present("only_file")
|
Some(true) == self.only_file || options.get_flag("only_file")
|
||||||
|
}
|
||||||
|
pub fn get_bars_on_right(&self, options: &ArgMatches) -> bool {
|
||||||
|
Some(true) == self.bars_on_right || options.get_flag("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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +165,7 @@ pub fn get_config() -> Config {
|
|||||||
mod tests {
|
mod tests {
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use super::*;
|
use super::*;
|
||||||
use clap::{Arg, ArgMatches, Command};
|
use clap::{value_parser, Arg, ArgMatches, Command};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_conversion() {
|
fn test_conversion() {
|
||||||
@@ -171,10 +185,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"), false), Some(2048));
|
assert_eq!(c._get_min_size(Some(&"2K".into()), 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"), true), Some(2000));
|
assert_eq!(c._get_min_size(Some(&"2K".into()), true), Some(2000));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -208,8 +222,12 @@ mod tests {
|
|||||||
|
|
||||||
fn get_args(args: Vec<&str>) -> ArgMatches {
|
fn get_args(args: Vec<&str>) -> ArgMatches {
|
||||||
Command::new("Dust")
|
Command::new("Dust")
|
||||||
.trailing_var_arg(true)
|
.arg(
|
||||||
.arg(Arg::new("depth").long("depth").takes_value(true))
|
Arg::new("depth")
|
||||||
|
.long("depth")
|
||||||
|
.num_args(1)
|
||||||
|
.value_parser(value_parser!(usize)),
|
||||||
|
)
|
||||||
.get_matches_from(args)
|
.get_matches_from(args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-10
@@ -1,9 +1,11 @@
|
|||||||
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;
|
||||||
@@ -28,16 +30,17 @@ 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);
|
||||||
|
|
||||||
@@ -126,10 +129,13 @@ 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 mut children = vec![];
|
let errors = &walk_data.errors;
|
||||||
|
|
||||||
if let Ok(entries) = fs::read_dir(&dir) {
|
let children = if dir.is_dir() {
|
||||||
children = entries
|
let read_dir = fs::read_dir(&dir);
|
||||||
|
match read_dir {
|
||||||
|
Ok(entries) => {
|
||||||
|
entries
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.par_bridge()
|
.par_bridge()
|
||||||
.filter_map(|entry| {
|
.filter_map(|entry| {
|
||||||
@@ -142,7 +148,9 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
|||||||
|
|
||||||
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() || (walk_data.follow_links && data.is_symlink()) {
|
if data.is_dir()
|
||||||
|
|| (walk_data.follow_links && data.is_symlink())
|
||||||
|
{
|
||||||
return walk(entry.path(), walk_data, depth + 1);
|
return walk(entry.path(), walk_data, depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,14 +175,37 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prog_data.no_permissions.store(true, ORDERING)
|
let mut editable_error = errors.lock().unwrap();
|
||||||
|
editable_error.no_permissions = true
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
})
|
})
|
||||||
.collect();
|
.collect()
|
||||||
} else if !dir.is_file() {
|
|
||||||
walk_data.progress_data.no_permissions.store(true, ORDERING)
|
|
||||||
}
|
}
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if !dir.is_file() {
|
||||||
|
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,
|
||||||
|
|||||||
+67
-1
@@ -24,6 +24,7 @@ pub struct InitialDisplayData {
|
|||||||
pub by_filecount: bool,
|
pub by_filecount: bool,
|
||||||
pub is_screen_reader: bool,
|
pub is_screen_reader: bool,
|
||||||
pub iso: bool,
|
pub iso: bool,
|
||||||
|
pub bars_on_right: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DisplayData {
|
pub struct DisplayData {
|
||||||
@@ -98,7 +99,13 @@ impl DrawData<'_> {
|
|||||||
let mut new_bar = "".to_string();
|
let mut new_bar = "".to_string();
|
||||||
let idx = 5 - level.clamp(1, 4);
|
let idx = 5 - level.clamp(1, 4);
|
||||||
|
|
||||||
for c in self.percent_bar.chars() {
|
let itr: Box<dyn Iterator<Item = char>> = if self.display_data.initial.bars_on_right {
|
||||||
|
Box::new(self.percent_bar.chars())
|
||||||
|
} else {
|
||||||
|
Box::new(self.percent_bar.chars().rev())
|
||||||
|
};
|
||||||
|
|
||||||
|
for c in itr {
|
||||||
num_not_my_bar -= 1;
|
num_not_my_bar -= 1;
|
||||||
if num_not_my_bar <= 0 {
|
if num_not_my_bar <= 0 {
|
||||||
new_bar.push(BLOCKS[0]);
|
new_bar.push(BLOCKS[0]);
|
||||||
@@ -108,7 +115,11 @@ impl DrawData<'_> {
|
|||||||
new_bar.push(c);
|
new_bar.push(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if self.display_data.initial.bars_on_right {
|
||||||
new_bar
|
new_bar
|
||||||
|
} else {
|
||||||
|
new_bar.chars().rev().collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,6 +437,7 @@ mod tests {
|
|||||||
by_filecount: false,
|
by_filecount: false,
|
||||||
is_screen_reader: false,
|
is_screen_reader: false,
|
||||||
iso: false,
|
iso: false,
|
||||||
|
bars_on_right: false,
|
||||||
};
|
};
|
||||||
DisplayData {
|
DisplayData {
|
||||||
initial,
|
initial,
|
||||||
@@ -508,4 +520,58 @@ mod tests {
|
|||||||
"1.0T"
|
"1.0T"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn build_draw_data<'a>(disp: &'a DisplayData, size: u32) -> (DrawData<'a>, DisplayNode) {
|
||||||
|
let n = DisplayNode {
|
||||||
|
name: PathBuf::from("/short"),
|
||||||
|
size: 2_u64.pow(size),
|
||||||
|
children: vec![],
|
||||||
|
};
|
||||||
|
let first_size_bar = repeat(BLOCKS[0]).take(13).collect();
|
||||||
|
let dd = DrawData {
|
||||||
|
indent: "".into(),
|
||||||
|
percent_bar: first_size_bar,
|
||||||
|
display_data: disp,
|
||||||
|
};
|
||||||
|
(dd, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_draw_data() {
|
||||||
|
let disp = &get_fake_display_data(20);
|
||||||
|
let (dd, n) = build_draw_data(disp, 12);
|
||||||
|
let bar = dd.generate_bar(&n, 1);
|
||||||
|
assert_eq!(bar, "█████████████");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_draw_data2() {
|
||||||
|
let disp = &get_fake_display_data(20);
|
||||||
|
let (dd, n) = build_draw_data(disp, 11);
|
||||||
|
let bar = dd.generate_bar(&n, 2);
|
||||||
|
assert_eq!(bar, "███████░░░░░░");
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_draw_data3() {
|
||||||
|
let mut disp = get_fake_display_data(20);
|
||||||
|
let (dd, n) = build_draw_data(&disp, 11);
|
||||||
|
let bar = dd.generate_bar(&n, 3);
|
||||||
|
assert_eq!(bar, "███████▒▒▒▒▒▒");
|
||||||
|
|
||||||
|
disp.initial.bars_on_right = true;
|
||||||
|
let (dd, n) = build_draw_data(&disp, 11);
|
||||||
|
let bar = dd.generate_bar(&n, 3);
|
||||||
|
assert_eq!(bar, "▒▒▒▒▒▒███████")
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_draw_data4() {
|
||||||
|
let disp = &get_fake_display_data(20);
|
||||||
|
let (dd, n) = build_draw_data(disp, 10);
|
||||||
|
// After 4 we have no more levels of shading so 4+ is the same
|
||||||
|
let bar = dd.generate_bar(&n, 4);
|
||||||
|
assert_eq!(bar, "████▓▓▓▓▓▓▓▓▓");
|
||||||
|
let bar = dd.generate_bar(&n, 5);
|
||||||
|
assert_eq!(bar, "████▓▓▓▓▓▓▓▓▓");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+98
-56
@@ -11,24 +11,26 @@ 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 progress::ORDERING;
|
use regex::Error;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::io::BufRead;
|
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;
|
||||||
@@ -87,7 +89,7 @@ fn get_width_of_terminal() -> usize {
|
|||||||
.unwrap_or(DEFAULT_TERMINAL_WIDTH)
|
.unwrap_or(DEFAULT_TERMINAL_WIDTH)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_regex_value(maybe_value: Option<Values>) -> Vec<Regex> {
|
fn get_regex_value(maybe_value: Option<ValuesRef<String>>) -> Vec<Regex> {
|
||||||
maybe_value
|
maybe_value
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.map(|reg| {
|
.map(|reg| {
|
||||||
@@ -99,67 +101,72 @@ fn get_regex_value(maybe_value: Option<Values>) -> Vec<Regex> {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a list of lines from stdin or `None` if there's nothing to read
|
|
||||||
fn get_lines_from_stdin() -> Option<Vec<String>> {
|
|
||||||
atty::isnt(atty::Stream::Stdin).then(|| {
|
|
||||||
std::io::stdin()
|
|
||||||
.lock()
|
|
||||||
.lines()
|
|
||||||
.collect::<Result<_, _>>()
|
|
||||||
.expect("Error reading from stdin")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let options = build_cli().get_matches();
|
let options = build_cli().get_matches();
|
||||||
let config = get_config();
|
let config = get_config();
|
||||||
let stdin_lines = get_lines_from_stdin();
|
|
||||||
|
|
||||||
let target_dirs = match options.values_of("inputs") {
|
let target_dirs = match options.get_many::<String>("params") {
|
||||||
Some(values) => values.collect(),
|
Some(values) => values.map(|v| v.as_str()).collect::<Vec<&str>>(),
|
||||||
None => stdin_lines.as_ref().map_or(vec!["."], |lines| {
|
None => vec!["."],
|
||||||
lines.iter().map(String::as_str).collect()
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let summarize_file_types = options.is_present("types");
|
let summarize_file_types = options.get_flag("types");
|
||||||
|
|
||||||
let filter_regexs = get_regex_value(options.values_of("filter"));
|
let filter_regexs = get_regex_value(options.get_many("filter"));
|
||||||
let invert_filter_regexs = get_regex_value(options.values_of("invert_filter"));
|
let invert_filter_regexs = get_regex_value(options.get_many("invert_filter"));
|
||||||
|
|
||||||
let terminal_width = options
|
let terminal_width: usize = match options.get_one::<usize>("width") {
|
||||||
.value_of_t("width")
|
Some(&val) => val,
|
||||||
.unwrap_or_else(|_| get_width_of_terminal());
|
None => 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") {
|
||||||
|
Some(&val) => val,
|
||||||
|
None => {
|
||||||
|
if depth != usize::MAX {
|
||||||
usize::MAX
|
usize::MAX
|
||||||
} else {
|
} else {
|
||||||
get_height_of_terminal()
|
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 = options
|
let ignore_directories = match options.get_many::<String>("ignore_directory") {
|
||||||
.values_of("ignore_directory")
|
Some(values) => values
|
||||||
.unwrap_or_default()
|
.map(|v| v.as_str())
|
||||||
.map(PathBuf::from);
|
.map(PathBuf::from)
|
||||||
|
.collect::<Vec<PathBuf>>(),
|
||||||
|
None => vec![],
|
||||||
|
};
|
||||||
|
|
||||||
let by_filecount = options.is_present("by_filecount");
|
let ignore_from_file_result = match options.get_one::<String>("ignore_all_in_file") {
|
||||||
let limit_filesystem = options.is_present("limit_filesystem");
|
Some(val) => read_to_string(val)
|
||||||
let follow_links = options.is_present("dereference_links");
|
.unwrap()
|
||||||
|
.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
|
||||||
@@ -167,6 +174,7 @@ 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();
|
||||||
|
|
||||||
@@ -189,14 +197,12 @@ 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 result = panic::catch_unwind(|| init_rayon);
|
let top_level_nodes = walk_it(simplified_dirs, &walk_data);
|
||||||
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),
|
||||||
@@ -207,19 +213,38 @@ 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: options.values_of("filter").is_some()
|
using_a_filter: !filter_regexs.is_empty() || !invert_filter_regexs.is_empty(),
|
||||||
|| options.value_of("invert_filter").is_some(),
|
|
||||||
};
|
};
|
||||||
get_biggest(top_level_nodes, agg_data)
|
get_biggest(top_level_nodes, agg_data)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let failed_permissions = indicator.data.no_permissions.load(ORDERING);
|
|
||||||
indicator.stop();
|
|
||||||
// Must have stopped indicator before we print to stderr
|
// Must have stopped indicator before we print to stderr
|
||||||
|
indicator.stop();
|
||||||
|
|
||||||
|
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 {
|
||||||
@@ -229,6 +254,7 @@ fn main() {
|
|||||||
by_filecount,
|
by_filecount,
|
||||||
iso,
|
iso,
|
||||||
is_screen_reader: config.get_screen_reader(&options),
|
is_screen_reader: config.get_screen_reader(&options),
|
||||||
|
bars_on_right: config.get_bars_on_right(&options),
|
||||||
};
|
};
|
||||||
draw_it(
|
draw_it(
|
||||||
idd,
|
idd,
|
||||||
@@ -240,7 +266,16 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_rayon() -> Result<(), ThreadPoolBuildError> {
|
fn init_rayon(stack_size: &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 large_stack = usize::pow(1024, 3);
|
||||||
let mut s = System::new();
|
let mut s = System::new();
|
||||||
s.refresh_memory();
|
s.refresh_memory();
|
||||||
@@ -254,4 +289,11 @@ fn init_rayon() -> Result<(), ThreadPoolBuildError> {
|
|||||||
} 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -1,8 +1,9 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
collections::HashSet,
|
||||||
io::Write,
|
io::Write,
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, AtomicU64, AtomicU8, AtomicUsize, Ordering},
|
atomic::{AtomicU64, AtomicU8, AtomicUsize, Ordering},
|
||||||
mpsc::{self, RecvTimeoutError, Sender},
|
mpsc::{self, RecvTimeoutError, Sender},
|
||||||
Arc, RwLock,
|
Arc, RwLock,
|
||||||
},
|
},
|
||||||
@@ -55,7 +56,6 @@ 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,6 +68,13 @@ 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 +1,2 @@
|
|||||||
hi
|
something
|
||||||
|
.secret
|
||||||
|
|||||||
@@ -52,7 +52,15 @@ fn exact_output_test<T: AsRef<OsStr>>(valid_outputs: Vec<String>, command_args:
|
|||||||
|
|
||||||
let output = str::from_utf8(&a.unwrap().stdout).unwrap().to_owned();
|
let output = str::from_utf8(&a.unwrap().stdout).unwrap().to_owned();
|
||||||
|
|
||||||
assert!(valid_outputs.iter().any(|i| output.contains(i)));
|
let will_fail = valid_outputs.iter().any(|i| output.contains(i));
|
||||||
|
if !will_fail {
|
||||||
|
eprintln!(
|
||||||
|
"output:\n{}\ndoes not contain any of:\n{}",
|
||||||
|
output,
|
||||||
|
valid_outputs.join("\n\n")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert!(will_fail)
|
||||||
}
|
}
|
||||||
|
|
||||||
// "windows" result data can vary by host (size seems to be variable by one byte); fix code vs test and re-enable
|
// "windows" result data can vary by host (size seems to be variable by one byte); fix code vs test and re-enable
|
||||||
@@ -60,7 +68,7 @@ fn exact_output_test<T: AsRef<OsStr>>(valid_outputs: Vec<String>, command_args:
|
|||||||
#[test]
|
#[test]
|
||||||
pub fn test_main_basic() {
|
pub fn test_main_basic() {
|
||||||
// -c is no color mode - This makes testing much simpler
|
// -c is no color mode - This makes testing much simpler
|
||||||
exact_output_test(main_output(), vec!["-c", "/tmp/test_dir/"])
|
exact_output_test(main_output(), vec!["-c", "-B", "/tmp/test_dir/"])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
@@ -68,6 +76,7 @@ pub fn test_main_basic() {
|
|||||||
pub fn test_main_multi_arg() {
|
pub fn test_main_multi_arg() {
|
||||||
let command_args = vec![
|
let command_args = vec![
|
||||||
"-c",
|
"-c",
|
||||||
|
"-B",
|
||||||
"/tmp/test_dir/many/",
|
"/tmp/test_dir/many/",
|
||||||
"/tmp/test_dir",
|
"/tmp/test_dir",
|
||||||
"/tmp/test_dir",
|
"/tmp/test_dir",
|
||||||
@@ -102,7 +111,7 @@ fn main_output() -> Vec<String> {
|
|||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_main_long_paths() {
|
pub fn test_main_long_paths() {
|
||||||
let command_args = vec!["-c", "-p", "/tmp/test_dir/"];
|
let command_args = vec!["-c", "-p", "-B", "/tmp/test_dir/"];
|
||||||
exact_output_test(main_output_long_paths(), command_args);
|
exact_output_test(main_output_long_paths(), command_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +139,7 @@ fn main_output_long_paths() -> Vec<String> {
|
|||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_substring_of_names_and_long_names() {
|
pub fn test_substring_of_names_and_long_names() {
|
||||||
let command_args = vec!["-c", "/tmp/test_dir2"];
|
let command_args = vec!["-c", "-B", "/tmp/test_dir2"];
|
||||||
exact_output_test(no_substring_of_names_output(), command_args);
|
exact_output_test(no_substring_of_names_output(), command_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +173,7 @@ fn no_substring_of_names_output() -> Vec<String> {
|
|||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_unicode_directories() {
|
pub fn test_unicode_directories() {
|
||||||
let command_args = vec!["-c", "/tmp/test_dir_unicode"];
|
let command_args = vec!["-c", "-B", "/tmp/test_dir_unicode"];
|
||||||
exact_output_test(unicode_dir(), command_args);
|
exact_output_test(unicode_dir(), command_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,12 +206,19 @@ pub fn test_apparent_size() {
|
|||||||
|
|
||||||
fn apparent_size_output() -> Vec<String> {
|
fn apparent_size_output() -> Vec<String> {
|
||||||
// The apparent directory sizes are too unpredictable and system dependent to try and match
|
// The apparent directory sizes are too unpredictable and system dependent to try and match
|
||||||
let files = r#"
|
let one_space_before = r#"
|
||||||
0B ┌── a_file
|
0B ┌── a_file
|
||||||
6B ├── hello_file
|
6B ├── hello_file
|
||||||
"#
|
"#
|
||||||
.trim()
|
.trim()
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
vec![files]
|
let two_space_before = r#"
|
||||||
|
0B ┌── a_file
|
||||||
|
6B ├── hello_file
|
||||||
|
"#
|
||||||
|
.trim()
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
vec![one_space_before, two_space_before]
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-2
@@ -64,6 +64,7 @@ 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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,14 +74,25 @@ 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("Did not have permissions for all directories"));
|
assert!(stderr.contains("No such file or directory"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user