mirror of
https://github.com/bootandy/dust.git
synced 2026-01-13 05:17:28 -08:00
Compare commits
1 Commits
tweak
...
fix_depth_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2cef68dfd |
784
Cargo.lock
generated
784
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
15
Cargo.toml
15
Cargo.toml
@@ -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 = "1.2.3"
|
version = "1.2.2"
|
||||||
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
|
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@@ -28,10 +28,10 @@ strip = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ansi_term = "0.12"
|
ansi_term = "0.12"
|
||||||
clap = { version = "4", features = ["derive"] }
|
clap = { version = "4.4", features = ["derive"] }
|
||||||
lscolors = "0.21"
|
lscolors = "0.13"
|
||||||
terminal_size = "0.4"
|
terminal_size = "0.2"
|
||||||
unicode-width = "0.2"
|
unicode-width = "0.1"
|
||||||
rayon = "1"
|
rayon = "1"
|
||||||
thousands = "0.2"
|
thousands = "0.2"
|
||||||
stfu8 = "0.2"
|
stfu8 = "0.2"
|
||||||
@@ -39,8 +39,9 @@ regex = "1"
|
|||||||
config-file = "0.2"
|
config-file = "0.2"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
sysinfo = "0.37"
|
directories = "4"
|
||||||
ctrlc = "3"
|
sysinfo = "0.27"
|
||||||
|
ctrlc = "3.4"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
|
||||||
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||||
|
|||||||
29
README.md
29
README.md
@@ -13,16 +13,6 @@ Because I want an easy way to see where my disk is being used.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
Study the above picture.
|
|
||||||
|
|
||||||
* We see `target` has 1.5G
|
|
||||||
* `target/debug` is the same size as `target` - so we know nearly all the disk usage of the 1.5G is in this folder
|
|
||||||
* `target/debug/deps` this is 1.0G - Note the bar jumps down to 70% to indiciate that most disk usage is here but not all.
|
|
||||||
* `target/debug/deps/dust-e78c9f87a17f24f3` - This is the largest file in this folder, but it is only 46M - Note the bar jumps down to 3% to indiciate the file is small.
|
|
||||||
* From here we can conclude:
|
|
||||||
* `target/debug/deps` takes 2/3 of the space in `target` and that `target/debug/deps` has a large number of relatively small files.
|
|
||||||
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
#### Cargo <a href="https://repology.org/project/du-dust/versions"><img src="https://repology.org/badge/vertical-allrepos/du-dust.svg" alt="Packaging status" align="right"></a>
|
#### Cargo <a href="https://repology.org/project/du-dust/versions"><img src="https://repology.org/badge/vertical-allrepos/du-dust.svg" alt="Packaging status" align="right"></a>
|
||||||
@@ -79,8 +69,6 @@ Dust will list a slightly-less-than-the-terminal-height number of the biggest su
|
|||||||
|
|
||||||
The different colors on the bars: These represent the combined tree hierarchy & disk usage. The shades of grey are used to indicate which parent folder a subfolder belongs to. For instance, look at the above screenshot. `.steam` is a folder taking 44% of the space. From the `.steam` bar is a light grey line that goes up. All these folders are inside `.steam` so if you delete `.steam` all that stuff will be gone too.
|
The different colors on the bars: These represent the combined tree hierarchy & disk usage. The shades of grey are used to indicate which parent folder a subfolder belongs to. For instance, look at the above screenshot. `.steam` is a folder taking 44% of the space. From the `.steam` bar is a light grey line that goes up. All these folders are inside `.steam` so if you delete `.steam` all that stuff will be gone too.
|
||||||
|
|
||||||
If you are new to the tool I recommend to try tweaking the `-n` parameter. `dust -n 10`, `dust -n 50`.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -114,8 +102,7 @@ Usage: dust -S (Custom Stack size - Use if you see: 'fatal runtime error: stack
|
|||||||
Usage: dust --skip-total (No total row will be displayed)
|
Usage: dust --skip-total (No total row will be displayed)
|
||||||
Usage: dust -z 40000/30MB/20kib (Exclude output files/directories below size 40000 bytes / 30MB / 20KiB)
|
Usage: dust -z 40000/30MB/20kib (Exclude output files/directories below size 40000 bytes / 30MB / 20KiB)
|
||||||
Usage: dust -j (Prints JSON representation of directories, try: dust -j | jq)
|
Usage: dust -j (Prints JSON representation of directories, try: dust -j | jq)
|
||||||
Usage: dust --files0-from=FILE (Read NUL-terminated file paths from FILE; if FILE is '-', read from stdin)
|
Usage: dust --files0-from=FILE (Reads null-terminated file paths from FILE); If FILE is - then read from stdin
|
||||||
Usage: dust --files-from=FILE (Read newline-terminated file paths from FILE; if FILE is '-', read from stdin)
|
|
||||||
Usage: dust --collapse=node-modules will keep the node-modules folder collapsed in display instead of recursively opening it
|
Usage: dust --collapse=node-modules will keep the node-modules folder collapsed in display instead of recursively opening it
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -135,16 +122,6 @@ reverse=true
|
|||||||
- [dua](https://github.com/Byron/dua-cli/)
|
- [dua](https://github.com/Byron/dua-cli/)
|
||||||
- [pdu](https://github.com/KSXGitHub/parallel-disk-usage)
|
- [pdu](https://github.com/KSXGitHub/parallel-disk-usage)
|
||||||
- [dirstat-rs](https://github.com/scullionw/dirstat-rs)
|
- [dirstat-rs](https://github.com/scullionw/dirstat-rs)
|
||||||
- `du -d 1 -h | sort -h`
|
- du -d 1 -h | sort -h
|
||||||
|
|
||||||
## Why to use Dust over the Alternatives
|
|
||||||
|
|
||||||
Dust simply Does The Right Thing when handling lots of small files & directories. Dust keeps the output simple by only showing large entries.
|
|
||||||
|
|
||||||
Tools like ncdu & baobab, give you a view of directory sizes but you have no idea where the largest files are. For example directory A could have a size larger than directory B, but in fact the largest file is in B and not A. Finding this out via these other tools is not trivial whereas Dust will show the large file clearly in the tree hierarchy
|
|
||||||
|
|
||||||
Dust will not count hard links multiple times (unless you want to `-s`).
|
|
||||||
|
|
||||||
Typing `dust -n 90` will show you your 90 largest entries. `-n` is not quite like `head -n` or `tail -n`, dust is intelligent and chooses the largest entries
|
|
||||||
|
|
||||||
|
|
||||||
|
Note: Apparent-size is calculated slightly differently in dust to gdu. In dust each hard link is counted as using file_length space. In gdu only the first entry is counted.
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ _dust() {
|
|||||||
'-T+[Number of threads to use]:THREADS:_default' \
|
'-T+[Number of threads to use]:THREADS:_default' \
|
||||||
'--threads=[Number of threads to use]:THREADS:_default' \
|
'--threads=[Number of threads to use]:THREADS:_default' \
|
||||||
'--config=[Specify a config file to use]:FILE:_files' \
|
'--config=[Specify a config file to use]:FILE:_files' \
|
||||||
'-n+[Display the '\''n'\'' largest entries. (Default is terminal_height)]:NUMBER:_default' \
|
'-n+[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER:_default' \
|
||||||
'--number-of-lines=[Display the '\''n'\'' largest entries. (Default is terminal_height)]:NUMBER:_default' \
|
'--number-of-lines=[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER:_default' \
|
||||||
'*-X+[Exclude any file or directory with this path]:PATH:_files' \
|
'*-X+[Exclude any file or directory with this path]:PATH:_files' \
|
||||||
'*--ignore-directory=[Exclude any file or directory with this path]:PATH:_files' \
|
'*--ignore-directory=[Exclude any file or directory with this path]:PATH:_files' \
|
||||||
'-I+[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:FILE:_files' \
|
'-I+[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:FILE:_files' \
|
||||||
@@ -62,8 +62,7 @@ tb\:"terabyte (TB)"))' \
|
|||||||
'--atime=[just like -mtime, but based on file access time]:ATIME:_default' \
|
'--atime=[just like -mtime, but based on file access time]:ATIME:_default' \
|
||||||
'-y+[just like -mtime, but based on file change time]:CTIME:_default' \
|
'-y+[just like -mtime, but based on file change time]:CTIME:_default' \
|
||||||
'--ctime=[just like -mtime, but based on file change time]:CTIME:_default' \
|
'--ctime=[just like -mtime, but based on file change time]:CTIME:_default' \
|
||||||
'(--files-from)--files0-from=[Read NUL-terminated paths from FILE (use \`-\` for stdin)]:FILES0_FROM:_files' \
|
'--files0-from=[run dust on NUL-terminated file names specified in file; if argument is -, then read names from standard input]:FILES0_FROM:_files' \
|
||||||
'(--files0-from)--files-from=[Read newline-terminated paths from FILE (use \`-\` for stdin)]:FILES_FROM:_files' \
|
|
||||||
'*--collapse=[Keep these directories collapsed]:COLLAPSE:_files' \
|
'*--collapse=[Keep these directories collapsed]:COLLAPSE:_files' \
|
||||||
'-m+[Directory '\''size'\'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time]:FILETIME:((a\:"last accessed time"
|
'-m+[Directory '\''size'\'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time]:FILETIME:((a\:"last accessed time"
|
||||||
c\:"last changed time"
|
c\:"last changed time"
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
|||||||
[CompletionResult]::new('-T', '-T ', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
[CompletionResult]::new('-T', '-T ', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
||||||
[CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
[CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
||||||
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'Specify a config file to use')
|
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'Specify a config file to use')
|
||||||
[CompletionResult]::new('-n', '-n', [CompletionResultType]::ParameterName, 'Display the ''n'' largest entries. (Default is terminal_height)')
|
[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, 'Display the ''n'' largest entries. (Default is terminal_height)')
|
[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 path')
|
[CompletionResult]::new('-X', '-X ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
||||||
[CompletionResult]::new('--ignore-directory', '--ignore-directory', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
[CompletionResult]::new('--ignore-directory', '--ignore-directory', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
||||||
[CompletionResult]::new('-I', '-I ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter')
|
[CompletionResult]::new('-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')
|
||||||
@@ -50,8 +50,7 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
|||||||
[CompletionResult]::new('--atime', '--atime', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file access time')
|
[CompletionResult]::new('--atime', '--atime', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file access time')
|
||||||
[CompletionResult]::new('-y', '-y', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file change time')
|
[CompletionResult]::new('-y', '-y', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file change time')
|
||||||
[CompletionResult]::new('--ctime', '--ctime', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file change time')
|
[CompletionResult]::new('--ctime', '--ctime', [CompletionResultType]::ParameterName, 'just like -mtime, but based on file change time')
|
||||||
[CompletionResult]::new('--files0-from', '--files0-from', [CompletionResultType]::ParameterName, 'Read NUL-terminated paths from FILE (use `-` for stdin)')
|
[CompletionResult]::new('--files0-from', '--files0-from', [CompletionResultType]::ParameterName, 'run dust on NUL-terminated file names specified in file; if argument is -, then read names from standard input')
|
||||||
[CompletionResult]::new('--files-from', '--files-from', [CompletionResultType]::ParameterName, 'Read newline-terminated paths from FILE (use `-` for stdin)')
|
|
||||||
[CompletionResult]::new('--collapse', '--collapse', [CompletionResultType]::ParameterName, 'Keep these directories collapsed')
|
[CompletionResult]::new('--collapse', '--collapse', [CompletionResultType]::ParameterName, 'Keep these directories collapsed')
|
||||||
[CompletionResult]::new('-m', '-m', [CompletionResultType]::ParameterName, 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time')
|
[CompletionResult]::new('-m', '-m', [CompletionResultType]::ParameterName, 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time')
|
||||||
[CompletionResult]::new('--filetime', '--filetime', [CompletionResultType]::ParameterName, 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time')
|
[CompletionResult]::new('--filetime', '--filetime', [CompletionResultType]::ParameterName, 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time')
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ _dust() {
|
|||||||
|
|
||||||
case "${cmd}" in
|
case "${cmd}" in
|
||||||
dust)
|
dust)
|
||||||
opts="-d -T -n -p -X -I -L -x -s -r -c -C -b -B -z -R -f -i -v -e -t -w -P -D -F -o -S -j -M -A -y -m -h -V --depth --threads --config --number-of-lines --full-paths --ignore-directory --ignore-all-in-file --dereference-links --limit-filesystem --apparent-size --reverse --no-colors --force-colors --no-percent-bars --bars-on-right --min-size --screen-reader --skip-total --filecount --ignore-hidden --invert-filter --filter --file-types --terminal-width --no-progress --print-errors --only-dir --only-file --output-format --stack-size --output-json --mtime --atime --ctime --files0-from --files-from --collapse --filetime --help --version [PATH]..."
|
opts="-d -T -n -p -X -I -L -x -s -r -c -C -b -B -z -R -f -i -v -e -t -w -P -D -F -o -S -j -M -A -y -m -h -V --depth --threads --config --number-of-lines --full-paths --ignore-directory --ignore-all-in-file --dereference-links --limit-filesystem --apparent-size --reverse --no-colors --force-colors --no-percent-bars --bars-on-right --min-size --screen-reader --skip-total --filecount --ignore-hidden --invert-filter --filter --file-types --terminal-width --no-progress --print-errors --only-dir --only-file --output-format --stack-size --output-json --mtime --atime --ctime --files0-from --collapse --filetime --help --version [PATH]..."
|
||||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||||
return 0
|
return 0
|
||||||
@@ -182,10 +182,6 @@ _dust() {
|
|||||||
COMPREPLY=($(compgen -f "${cur}"))
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--files-from)
|
|
||||||
COMPREPLY=($(compgen -f "${cur}"))
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
--collapse)
|
--collapse)
|
||||||
COMPREPLY=($(compgen -f "${cur}"))
|
COMPREPLY=($(compgen -f "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ set edit:completion:arg-completer[dust] = {|@words|
|
|||||||
cand -T 'Number of threads to use'
|
cand -T 'Number of threads to use'
|
||||||
cand --threads 'Number of threads to use'
|
cand --threads 'Number of threads to use'
|
||||||
cand --config 'Specify a config file to use'
|
cand --config 'Specify a config file to use'
|
||||||
cand -n 'Display the ''n'' largest entries. (Default is terminal_height)'
|
cand -n 'Number of lines of output to show. (Default is terminal_height - 10)'
|
||||||
cand --number-of-lines 'Display the ''n'' largest entries. (Default is terminal_height)'
|
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 path'
|
cand -X 'Exclude any file or directory with this path'
|
||||||
cand --ignore-directory 'Exclude any file or directory with this path'
|
cand --ignore-directory 'Exclude any file or directory with this path'
|
||||||
cand -I 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter'
|
cand -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'
|
||||||
@@ -47,8 +47,7 @@ set edit:completion:arg-completer[dust] = {|@words|
|
|||||||
cand --atime 'just like -mtime, but based on file access time'
|
cand --atime 'just like -mtime, but based on file access time'
|
||||||
cand -y 'just like -mtime, but based on file change time'
|
cand -y 'just like -mtime, but based on file change time'
|
||||||
cand --ctime 'just like -mtime, but based on file change time'
|
cand --ctime 'just like -mtime, but based on file change time'
|
||||||
cand --files0-from 'Read NUL-terminated paths from FILE (use `-` for stdin)'
|
cand --files0-from 'run dust on NUL-terminated file names specified in file; if argument is -, then read names from standard input'
|
||||||
cand --files-from 'Read newline-terminated paths from FILE (use `-` for stdin)'
|
|
||||||
cand --collapse 'Keep these directories collapsed'
|
cand --collapse 'Keep these directories collapsed'
|
||||||
cand -m 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time'
|
cand -m 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time'
|
||||||
cand --filetime 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time'
|
cand --filetime 'Directory ''size'' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
complete -c dust -s d -l depth -d 'Depth to show' -r
|
complete -c dust -s d -l depth -d 'Depth to show' -r
|
||||||
complete -c dust -s T -l threads -d 'Number of threads to use' -r
|
complete -c dust -s T -l threads -d 'Number of threads to use' -r
|
||||||
complete -c dust -l config -d 'Specify a config file to use' -r -F
|
complete -c dust -l config -d 'Specify a config file to use' -r -F
|
||||||
complete -c dust -s n -l number-of-lines -d 'Display the \'n\' largest entries. (Default is terminal_height)' -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 path' -r -F
|
complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this path' -r -F
|
||||||
complete -c dust -s I -l ignore-all-in-file -d 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter' -r -F
|
complete -c dust -s I -l ignore-all-in-file -d 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter' -r -F
|
||||||
complete -c dust -s z -l min-size -d 'Minimum size file to include in output' -r
|
complete -c dust -s z -l min-size -d 'Minimum size file to include in output' -r
|
||||||
@@ -22,8 +22,7 @@ complete -c dust -s S -l stack-size -d 'Specify memory to use as stack size - us
|
|||||||
complete -c dust -s M -l mtime -d '+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)' -r
|
complete -c dust -s M -l mtime -d '+/-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and -n => (𝑐𝑢𝑟𝑟−𝑛, +∞)' -r
|
||||||
complete -c dust -s A -l atime -d 'just like -mtime, but based on file access time' -r
|
complete -c dust -s A -l atime -d 'just like -mtime, but based on file access time' -r
|
||||||
complete -c dust -s y -l ctime -d 'just like -mtime, but based on file change time' -r
|
complete -c dust -s y -l ctime -d 'just like -mtime, but based on file change time' -r
|
||||||
complete -c dust -l files0-from -d 'Read NUL-terminated paths from FILE (use `-` for stdin)' -r -F
|
complete -c dust -l files0-from -d 'run dust on NUL-terminated file names specified in file; if argument is -, then read names from standard input' -r -F
|
||||||
complete -c dust -l files-from -d 'Read newline-terminated paths from FILE (use `-` for stdin)' -r -F
|
|
||||||
complete -c dust -l collapse -d 'Keep these directories collapsed' -r -F
|
complete -c dust -l collapse -d 'Keep these directories collapsed' -r -F
|
||||||
complete -c dust -s m -l filetime -d 'Directory \'size\' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time' -r -f -a "a\t'last accessed time'
|
complete -c dust -s m -l filetime -d 'Directory \'size\' is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time' -r -f -a "a\t'last accessed time'
|
||||||
c\t'last changed time'
|
c\t'last changed time'
|
||||||
|
|||||||
@@ -25,6 +25,4 @@ skip-total=true
|
|||||||
ignore-hidden=true
|
ignore-hidden=true
|
||||||
|
|
||||||
# print sizes in powers of 1000 (e.g., 1.1G)
|
# print sizes in powers of 1000 (e.g., 1.1G)
|
||||||
output-format="si"
|
output-format="si"
|
||||||
|
|
||||||
number-of-lines=5
|
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
.ie \n(.g .ds Aq \(aq
|
.ie \n(.g .ds Aq \(aq
|
||||||
.el .ds Aq '
|
.el .ds Aq '
|
||||||
.TH Dust 1 "Dust 1.2.3"
|
.TH Dust 1 "Dust 1.2.2"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Dust \- Like du but more intuitive
|
Dust \- Like du but more intuitive
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
\fBdust\fR [\fB\-d\fR|\fB\-\-depth\fR] [\fB\-T\fR|\fB\-\-threads\fR] [\fB\-\-config\fR] [\fB\-n\fR|\fB\-\-number\-of\-lines\fR] [\fB\-p\fR|\fB\-\-full\-paths\fR] [\fB\-X\fR|\fB\-\-ignore\-directory\fR] [\fB\-I\fR|\fB\-\-ignore\-all\-in\-file\fR] [\fB\-L\fR|\fB\-\-dereference\-links\fR] [\fB\-x\fR|\fB\-\-limit\-filesystem\fR] [\fB\-s\fR|\fB\-\-apparent\-size\fR] [\fB\-r\fR|\fB\-\-reverse\fR] [\fB\-c\fR|\fB\-\-no\-colors\fR] [\fB\-C\fR|\fB\-\-force\-colors\fR] [\fB\-b\fR|\fB\-\-no\-percent\-bars\fR] [\fB\-B\fR|\fB\-\-bars\-on\-right\fR] [\fB\-z\fR|\fB\-\-min\-size\fR] [\fB\-R\fR|\fB\-\-screen\-reader\fR] [\fB\-\-skip\-total\fR] [\fB\-f\fR|\fB\-\-filecount\fR] [\fB\-i\fR|\fB\-\-ignore\-hidden\fR] [\fB\-v\fR|\fB\-\-invert\-filter\fR] [\fB\-e\fR|\fB\-\-filter\fR] [\fB\-t\fR|\fB\-\-file\-types\fR] [\fB\-w\fR|\fB\-\-terminal\-width\fR] [\fB\-P\fR|\fB\-\-no\-progress\fR] [\fB\-\-print\-errors\fR] [\fB\-D\fR|\fB\-\-only\-dir\fR] [\fB\-F\fR|\fB\-\-only\-file\fR] [\fB\-o\fR|\fB\-\-output\-format\fR] [\fB\-S\fR|\fB\-\-stack\-size\fR] [\fB\-j\fR|\fB\-\-output\-json\fR] [\fB\-M\fR|\fB\-\-mtime\fR] [\fB\-A\fR|\fB\-\-atime\fR] [\fB\-y\fR|\fB\-\-ctime\fR] [\fB\-\-files0\-from\fR] [\fB\-\-files\-from\fR] [\fB\-\-collapse\fR] [\fB\-m\fR|\fB\-\-filetime\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIPATH\fR]
|
\fBdust\fR [\fB\-d\fR|\fB\-\-depth\fR] [\fB\-T\fR|\fB\-\-threads\fR] [\fB\-\-config\fR] [\fB\-n\fR|\fB\-\-number\-of\-lines\fR] [\fB\-p\fR|\fB\-\-full\-paths\fR] [\fB\-X\fR|\fB\-\-ignore\-directory\fR] [\fB\-I\fR|\fB\-\-ignore\-all\-in\-file\fR] [\fB\-L\fR|\fB\-\-dereference\-links\fR] [\fB\-x\fR|\fB\-\-limit\-filesystem\fR] [\fB\-s\fR|\fB\-\-apparent\-size\fR] [\fB\-r\fR|\fB\-\-reverse\fR] [\fB\-c\fR|\fB\-\-no\-colors\fR] [\fB\-C\fR|\fB\-\-force\-colors\fR] [\fB\-b\fR|\fB\-\-no\-percent\-bars\fR] [\fB\-B\fR|\fB\-\-bars\-on\-right\fR] [\fB\-z\fR|\fB\-\-min\-size\fR] [\fB\-R\fR|\fB\-\-screen\-reader\fR] [\fB\-\-skip\-total\fR] [\fB\-f\fR|\fB\-\-filecount\fR] [\fB\-i\fR|\fB\-\-ignore\-hidden\fR] [\fB\-v\fR|\fB\-\-invert\-filter\fR] [\fB\-e\fR|\fB\-\-filter\fR] [\fB\-t\fR|\fB\-\-file\-types\fR] [\fB\-w\fR|\fB\-\-terminal\-width\fR] [\fB\-P\fR|\fB\-\-no\-progress\fR] [\fB\-\-print\-errors\fR] [\fB\-D\fR|\fB\-\-only\-dir\fR] [\fB\-F\fR|\fB\-\-only\-file\fR] [\fB\-o\fR|\fB\-\-output\-format\fR] [\fB\-S\fR|\fB\-\-stack\-size\fR] [\fB\-j\fR|\fB\-\-output\-json\fR] [\fB\-M\fR|\fB\-\-mtime\fR] [\fB\-A\fR|\fB\-\-atime\fR] [\fB\-y\fR|\fB\-\-ctime\fR] [\fB\-\-files0\-from\fR] [\fB\-\-collapse\fR] [\fB\-m\fR|\fB\-\-filetime\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIPATH\fR]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Like du but more intuitive
|
Like du but more intuitive
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
\fB\-d\fR, \fB\-\-depth\fR \fI<DEPTH>\fR
|
\fB\-d\fR, \fB\-\-depth\fR=\fIDEPTH\fR
|
||||||
Depth to show
|
Depth to show
|
||||||
.TP
|
.TP
|
||||||
\fB\-T\fR, \fB\-\-threads\fR \fI<THREADS>\fR
|
\fB\-T\fR, \fB\-\-threads\fR=\fITHREADS\fR
|
||||||
Number of threads to use
|
Number of threads to use
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-config\fR \fI<FILE>\fR
|
\fB\-\-config\fR=\fIFILE\fR
|
||||||
Specify a config file to use
|
Specify a config file to use
|
||||||
.TP
|
.TP
|
||||||
\fB\-n\fR, \fB\-\-number\-of\-lines\fR \fI<NUMBER>\fR
|
\fB\-n\fR, \fB\-\-number\-of\-lines\fR=\fINUMBER\fR
|
||||||
Display the \*(Aqn\*(Aq largest entries. (Default is terminal_height)
|
Number of lines of output to show. (Default is terminal_height \- 10)
|
||||||
.TP
|
.TP
|
||||||
\fB\-p\fR, \fB\-\-full\-paths\fR
|
\fB\-p\fR, \fB\-\-full\-paths\fR
|
||||||
Subdirectories will not have their path shortened
|
Subdirectories will not have their path shortened
|
||||||
.TP
|
.TP
|
||||||
\fB\-X\fR, \fB\-\-ignore\-directory\fR \fI<PATH>\fR
|
\fB\-X\fR, \fB\-\-ignore\-directory\fR=\fIPATH\fR
|
||||||
Exclude any file or directory with this path
|
Exclude any file or directory with this path
|
||||||
.TP
|
.TP
|
||||||
\fB\-I\fR, \fB\-\-ignore\-all\-in\-file\fR \fI<FILE>\fR
|
\fB\-I\fR, \fB\-\-ignore\-all\-in\-file\fR=\fIFILE\fR
|
||||||
Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by \-\-invert_filter
|
Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by \-\-invert_filter
|
||||||
.TP
|
.TP
|
||||||
\fB\-L\fR, \fB\-\-dereference\-links\fR
|
\fB\-L\fR, \fB\-\-dereference\-links\fR
|
||||||
@@ -54,7 +54,7 @@ No percent bars or percentages will be displayed
|
|||||||
\fB\-B\fR, \fB\-\-bars\-on\-right\fR
|
\fB\-B\fR, \fB\-\-bars\-on\-right\fR
|
||||||
percent bars moved to right side of screen
|
percent bars moved to right side of screen
|
||||||
.TP
|
.TP
|
||||||
\fB\-z\fR, \fB\-\-min\-size\fR \fI<MIN_SIZE>\fR
|
\fB\-z\fR, \fB\-\-min\-size\fR=\fIMIN_SIZE\fR
|
||||||
Minimum size file to include in output
|
Minimum size file to include in output
|
||||||
.TP
|
.TP
|
||||||
\fB\-R\fR, \fB\-\-screen\-reader\fR
|
\fB\-R\fR, \fB\-\-screen\-reader\fR
|
||||||
@@ -69,16 +69,16 @@ Directory \*(Aqsize\*(Aq is number of child files instead of disk size
|
|||||||
\fB\-i\fR, \fB\-\-ignore\-hidden\fR
|
\fB\-i\fR, \fB\-\-ignore\-hidden\fR
|
||||||
Do not display hidden files
|
Do not display hidden files
|
||||||
.TP
|
.TP
|
||||||
\fB\-v\fR, \fB\-\-invert\-filter\fR \fI<REGEX>\fR
|
\fB\-v\fR, \fB\-\-invert\-filter\fR=\fIREGEX\fR
|
||||||
Exclude filepaths matching this regex. To ignore png files type: \-v "\\.png$"
|
Exclude filepaths matching this regex. To ignore png files type: \-v "\\.png$"
|
||||||
.TP
|
.TP
|
||||||
\fB\-e\fR, \fB\-\-filter\fR \fI<REGEX>\fR
|
\fB\-e\fR, \fB\-\-filter\fR=\fIREGEX\fR
|
||||||
Only include filepaths matching this regex. For png files type: \-e "\\.png$"
|
Only include filepaths matching this regex. For png files type: \-e "\\.png$"
|
||||||
.TP
|
.TP
|
||||||
\fB\-t\fR, \fB\-\-file\-types\fR
|
\fB\-t\fR, \fB\-\-file\-types\fR
|
||||||
show only these file types
|
show only these file types
|
||||||
.TP
|
.TP
|
||||||
\fB\-w\fR, \fB\-\-terminal\-width\fR \fI<WIDTH>\fR
|
\fB\-w\fR, \fB\-\-terminal\-width\fR=\fIWIDTH\fR
|
||||||
Specify width of output overriding the auto detection of terminal width
|
Specify width of output overriding the auto detection of terminal width
|
||||||
.TP
|
.TP
|
||||||
\fB\-P\fR, \fB\-\-no\-progress\fR
|
\fB\-P\fR, \fB\-\-no\-progress\fR
|
||||||
@@ -93,7 +93,7 @@ Only directories will be displayed
|
|||||||
\fB\-F\fR, \fB\-\-only\-file\fR
|
\fB\-F\fR, \fB\-\-only\-file\fR
|
||||||
Only files will be displayed. (Finds your largest files)
|
Only files will be displayed. (Finds your largest files)
|
||||||
.TP
|
.TP
|
||||||
\fB\-o\fR, \fB\-\-output\-format\fR \fI<FORMAT>\fR
|
\fB\-o\fR, \fB\-\-output\-format\fR=\fIFORMAT\fR
|
||||||
Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size
|
Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size
|
||||||
.br
|
.br
|
||||||
|
|
||||||
@@ -122,31 +122,28 @@ gb: gigabyte (GB)
|
|||||||
tb: terabyte (TB)
|
tb: terabyte (TB)
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
\fB\-S\fR, \fB\-\-stack\-size\fR \fI<STACK_SIZE>\fR
|
\fB\-S\fR, \fB\-\-stack\-size\fR=\fISTACK_SIZE\fR
|
||||||
Specify memory to use as stack size \- use if you see: \*(Aqfatal runtime error: stack overflow\*(Aq (default low memory=1048576, high memory=1073741824)
|
Specify memory to use as stack size \- use if you see: \*(Aqfatal runtime error: stack overflow\*(Aq (default low memory=1048576, high memory=1073741824)
|
||||||
.TP
|
.TP
|
||||||
\fB\-j\fR, \fB\-\-output\-json\fR
|
\fB\-j\fR, \fB\-\-output\-json\fR
|
||||||
Output the directory tree as json to the current directory
|
Output the directory tree as json to the current directory
|
||||||
.TP
|
.TP
|
||||||
\fB\-M\fR, \fB\-\-mtime\fR \fI<MTIME>\fR
|
\fB\-M\fR, \fB\-\-mtime\fR=\fIMTIME\fR
|
||||||
+/\-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and \-n => (𝑐𝑢𝑟𝑟−𝑛, +∞)
|
+/\-n matches files modified more/less than n days ago , and n matches files modified exactly n days ago, days are rounded down.That is +n => (−∞, curr−(n+1)), n => [curr−(n+1), curr−n), and \-n => (𝑐𝑢𝑟𝑟−𝑛, +∞)
|
||||||
.TP
|
.TP
|
||||||
\fB\-A\fR, \fB\-\-atime\fR \fI<ATIME>\fR
|
\fB\-A\fR, \fB\-\-atime\fR=\fIATIME\fR
|
||||||
just like \-mtime, but based on file access time
|
just like \-mtime, but based on file access time
|
||||||
.TP
|
.TP
|
||||||
\fB\-y\fR, \fB\-\-ctime\fR \fI<CTIME>\fR
|
\fB\-y\fR, \fB\-\-ctime\fR=\fICTIME\fR
|
||||||
just like \-mtime, but based on file change time
|
just like \-mtime, but based on file change time
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-files0\-from\fR \fI<FILES0_FROM>\fR
|
\fB\-\-files0\-from\fR=\fIFILES0_FROM\fR
|
||||||
Read NUL\-terminated paths from FILE (use `\-` for stdin)
|
run dust on NUL\-terminated file names specified in file; if argument is \-, then read names from standard input
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-files\-from\fR \fI<FILES_FROM>\fR
|
\fB\-\-collapse\fR=\fICOLLAPSE\fR
|
||||||
Read newline\-terminated paths from FILE (use `\-` for stdin)
|
|
||||||
.TP
|
|
||||||
\fB\-\-collapse\fR \fI<COLLAPSE>\fR
|
|
||||||
Keep these directories collapsed
|
Keep these directories collapsed
|
||||||
.TP
|
.TP
|
||||||
\fB\-m\fR, \fB\-\-filetime\fR \fI<FILETIME>\fR
|
\fB\-m\fR, \fB\-\-filetime\fR=\fIFILETIME\fR
|
||||||
Directory \*(Aqsize\*(Aq is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time
|
Directory \*(Aqsize\*(Aq is max filetime of child files instead of disk size. while a/c/m for last accessed/changed/modified time
|
||||||
.br
|
.br
|
||||||
|
|
||||||
@@ -170,4 +167,4 @@ Print version
|
|||||||
[\fIPATH\fR]
|
[\fIPATH\fR]
|
||||||
Input files or directories
|
Input files or directories
|
||||||
.SH VERSION
|
.SH VERSION
|
||||||
v1.2.3
|
v1.2.2
|
||||||
|
|||||||
BIN
media/snap.png
BIN
media/snap.png
Binary file not shown.
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 61 KiB |
11
src/cli.rs
11
src/cli.rs
@@ -21,7 +21,7 @@ pub struct Cli {
|
|||||||
#[arg(long, value_name("FILE"), value_hint(ValueHint::FilePath))]
|
#[arg(long, value_name("FILE"), value_hint(ValueHint::FilePath))]
|
||||||
pub config: Option<String>,
|
pub config: Option<String>,
|
||||||
|
|
||||||
/// Display the 'n' largest entries. (Default is terminal_height)
|
/// Number of lines of output to show. (Default is terminal_height - 10)
|
||||||
#[arg(short, long, value_name("NUMBER"))]
|
#[arg(short, long, value_name("NUMBER"))]
|
||||||
pub number_of_lines: Option<usize>,
|
pub number_of_lines: Option<usize>,
|
||||||
|
|
||||||
@@ -172,14 +172,11 @@ pub struct Cli {
|
|||||||
#[arg(short('y'), long, allow_hyphen_values(true))]
|
#[arg(short('y'), long, allow_hyphen_values(true))]
|
||||||
pub ctime: Option<String>,
|
pub ctime: Option<String>,
|
||||||
|
|
||||||
/// Read NUL-terminated paths from FILE (use `-` for stdin).
|
/// run dust on NUL-terminated file names specified in file; if argument is
|
||||||
#[arg(long, value_hint(ValueHint::AnyPath), conflicts_with("files_from"))]
|
/// -, then read names from standard input
|
||||||
|
#[arg(long, value_hint(ValueHint::AnyPath))]
|
||||||
pub files0_from: Option<String>,
|
pub files0_from: Option<String>,
|
||||||
|
|
||||||
/// Read newline-terminated paths from FILE (use `-` for stdin).
|
|
||||||
#[arg(long, value_hint(ValueHint::AnyPath), conflicts_with("files0_from"))]
|
|
||||||
pub files_from: Option<String>,
|
|
||||||
|
|
||||||
/// Keep these directories collapsed
|
/// Keep these directories collapsed
|
||||||
#[arg(long, value_hint(ValueHint::AnyPath))]
|
#[arg(long, value_hint(ValueHint::AnyPath))]
|
||||||
pub collapse: Option<Vec<String>>,
|
pub collapse: Option<Vec<String>>,
|
||||||
|
|||||||
@@ -36,26 +36,16 @@ pub struct Config {
|
|||||||
pub output_json: Option<bool>,
|
pub output_json: Option<bool>,
|
||||||
pub print_errors: Option<bool>,
|
pub print_errors: Option<bool>,
|
||||||
pub files0_from: Option<String>,
|
pub files0_from: Option<String>,
|
||||||
pub number_of_lines: Option<usize>,
|
|
||||||
pub files_from: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn get_files0_from(&self, options: &Cli) -> Option<String> {
|
pub fn get_files_from(&self, options: &Cli) -> Option<String> {
|
||||||
let from_file = &options.files0_from;
|
let from_file = &options.files0_from;
|
||||||
match from_file {
|
match from_file {
|
||||||
None => self.files0_from.as_ref().map(|x| x.to_string()),
|
None => self.files0_from.as_ref().map(|x| x.to_string()),
|
||||||
Some(x) => Some(x.to_string()),
|
Some(x) => Some(x.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_files_from(&self, options: &Cli) -> Option<String> {
|
|
||||||
let from_file = &options.files_from;
|
|
||||||
match from_file {
|
|
||||||
None => self.files_from.as_ref().map(|x| x.to_string()),
|
|
||||||
Some(x) => Some(x.to_string()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn get_no_colors(&self, options: &Cli) -> bool {
|
pub fn get_no_colors(&self, options: &Cli) -> bool {
|
||||||
Some(true) == self.no_colors || options.no_colors
|
Some(true) == self.no_colors || options.no_colors
|
||||||
}
|
}
|
||||||
@@ -157,15 +147,6 @@ impl Config {
|
|||||||
Some(true) == self.output_json || options.output_json
|
Some(true) == self.output_json || options.output_json
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_number_of_lines(&self, options: &Cli) -> Option<usize> {
|
|
||||||
let from_cmd_line = options.number_of_lines;
|
|
||||||
if from_cmd_line.is_none() {
|
|
||||||
self.number_of_lines
|
|
||||||
} else {
|
|
||||||
from_cmd_line
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_modified_time_operator(&self, options: &Cli) -> Option<(Operator, i64)> {
|
pub fn get_modified_time_operator(&self, options: &Cli) -> Option<(Operator, i64)> {
|
||||||
get_filter_time_operator(options.mtime.as_ref(), get_current_date_epoch_seconds())
|
get_filter_time_operator(options.mtime.as_ref(), get_current_date_epoch_seconds())
|
||||||
}
|
}
|
||||||
@@ -244,7 +225,7 @@ fn convert_min_size(input: &str) -> Option<usize> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_config_locations(base: PathBuf) -> Vec<PathBuf> {
|
fn get_config_locations(base: &Path) -> Vec<PathBuf> {
|
||||||
vec![
|
vec![
|
||||||
base.join(".dust.toml"),
|
base.join(".dust.toml"),
|
||||||
base.join(".config").join("dust").join("config.toml"),
|
base.join(".config").join("dust").join("config.toml"),
|
||||||
@@ -267,12 +248,12 @@ pub fn get_config(conf_path: Option<&String>) -> Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if let Some(home) = std::env::home_dir() {
|
if let Some(home) = directories::BaseDirs::new() {
|
||||||
for path in get_config_locations(home) {
|
for path in get_config_locations(home.home_dir()) {
|
||||||
if path.exists()
|
if path.exists() {
|
||||||
&& let Ok(config) = Config::from_config_file(&path)
|
if let Ok(config) = Config::from_config_file(&path) {
|
||||||
{
|
return config;
|
||||||
return config;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -399,33 +380,4 @@ mod tests {
|
|||||||
fn get_filetime_args(args: Vec<&str>) -> Cli {
|
fn get_filetime_args(args: Vec<&str>) -> Cli {
|
||||||
Cli::parse_from(args)
|
Cli::parse_from(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_get_number_of_lines() {
|
|
||||||
// No config and no flag.
|
|
||||||
let c = Config::default();
|
|
||||||
let args = get_args(vec![]);
|
|
||||||
assert_eq!(c.get_number_of_lines(&args), None);
|
|
||||||
|
|
||||||
// Config is not defined and flag is defined.
|
|
||||||
let c = Config::default();
|
|
||||||
let args = get_args(vec!["dust", "--number-of-lines", "5"]);
|
|
||||||
assert_eq!(c.get_number_of_lines(&args), Some(5));
|
|
||||||
|
|
||||||
// Config is defined and flag is not defined.
|
|
||||||
let c = Config {
|
|
||||||
number_of_lines: Some(3),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let args = get_args(vec![]);
|
|
||||||
assert_eq!(c.get_number_of_lines(&args), Some(3));
|
|
||||||
|
|
||||||
// Both config and flag are defined.
|
|
||||||
let c = Config {
|
|
||||||
number_of_lines: Some(3),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let args = get_args(vec!["dust", "--number-of-lines", "5"]);
|
|
||||||
assert_eq!(c.get_number_of_lines(&args), Some(5));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,11 +69,12 @@ pub fn walk_it(dirs: HashSet<PathBuf>, walk_data: &WalkData) -> Vec<Node> {
|
|||||||
|
|
||||||
// Remove files which have the same inode, we don't want to double count them.
|
// Remove files which have the same inode, we don't want to double count them.
|
||||||
fn clean_inodes(x: Node, inodes: &mut HashSet<(u64, u64)>, walk_data: &WalkData) -> Option<Node> {
|
fn clean_inodes(x: Node, inodes: &mut HashSet<(u64, u64)>, walk_data: &WalkData) -> Option<Node> {
|
||||||
if !walk_data.use_apparent_size
|
if !walk_data.use_apparent_size {
|
||||||
&& let Some(id) = x.inode_device
|
if let Some(id) = x.inode_device {
|
||||||
&& !inodes.insert(id)
|
if !inodes.insert(id) {
|
||||||
{
|
return None;
|
||||||
return None;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort Nodes so iteration order is predictable
|
// Sort Nodes so iteration order is predictable
|
||||||
@@ -155,10 +156,10 @@ fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
|
|||||||
|
|
||||||
if !walk_data.allowed_filesystems.is_empty() {
|
if !walk_data.allowed_filesystems.is_empty() {
|
||||||
let size_inode_device = get_metadata(entry.path(), false, follow_links);
|
let size_inode_device = get_metadata(entry.path(), false, follow_links);
|
||||||
if let Some((_size, Some((_id, dev)), _gunk)) = size_inode_device
|
if let Some((_size, Some((_id, dev)), _gunk)) = size_inode_device {
|
||||||
&& !walk_data.allowed_filesystems.contains(&dev)
|
if !walk_data.allowed_filesystems.contains(&dev) {
|
||||||
{
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if walk_data.filter_accessed_time.is_some()
|
if walk_data.filter_accessed_time.is_some()
|
||||||
@@ -166,19 +167,20 @@ fn ignore_file(entry: &DirEntry, walk_data: &WalkData) -> bool {
|
|||||||
|| walk_data.filter_changed_time.is_some()
|
|| walk_data.filter_changed_time.is_some()
|
||||||
{
|
{
|
||||||
let size_inode_device = get_metadata(entry.path(), false, follow_links);
|
let size_inode_device = get_metadata(entry.path(), false, follow_links);
|
||||||
if let Some((_, _, (modified_time, accessed_time, changed_time))) = size_inode_device
|
if let Some((_, _, (modified_time, accessed_time, changed_time))) = size_inode_device {
|
||||||
&& entry.path().is_file()
|
if entry.path().is_file()
|
||||||
&& [
|
&& [
|
||||||
(&walk_data.filter_modified_time, modified_time),
|
(&walk_data.filter_modified_time, modified_time),
|
||||||
(&walk_data.filter_accessed_time, accessed_time),
|
(&walk_data.filter_accessed_time, accessed_time),
|
||||||
(&walk_data.filter_changed_time, changed_time),
|
(&walk_data.filter_changed_time, changed_time),
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
.any(|(filter_time, actual_time)| {
|
.any(|(filter_time, actual_time)| {
|
||||||
is_filtered_out_due_to_file_time(filter_time, *actual_time)
|
is_filtered_out_due_to_file_time(filter_time, *actual_time)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,30 +222,32 @@ fn walk(dir: PathBuf, walk_data: &WalkData, depth: usize) -> Option<Node> {
|
|||||||
|
|
||||||
// return walk(entry.path(), walk_data, depth)
|
// return walk(entry.path(), walk_data, depth)
|
||||||
|
|
||||||
if !ignore_file(entry, walk_data)
|
if !ignore_file(entry, walk_data) {
|
||||||
&& let Ok(data) = entry.file_type()
|
if let Ok(data) = entry.file_type() {
|
||||||
{
|
if data.is_dir()
|
||||||
if data.is_dir()
|
|| (walk_data.follow_links && data.is_symlink())
|
||||||
|| (walk_data.follow_links && data.is_symlink())
|
{
|
||||||
{
|
return walk(entry.path(), walk_data, depth + 1);
|
||||||
return walk(entry.path(), walk_data, depth + 1);
|
}
|
||||||
|
|
||||||
|
let node = build_node(
|
||||||
|
entry.path(),
|
||||||
|
vec![],
|
||||||
|
data.is_symlink(),
|
||||||
|
data.is_file(),
|
||||||
|
depth,
|
||||||
|
walk_data,
|
||||||
|
);
|
||||||
|
|
||||||
|
prog_data.num_files.fetch_add(1, ORDERING);
|
||||||
|
if let Some(ref file) = node {
|
||||||
|
prog_data
|
||||||
|
.total_file_size
|
||||||
|
.fetch_add(file.size, ORDERING);
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
let node = build_node(
|
|
||||||
entry.path(),
|
|
||||||
vec![],
|
|
||||||
data.is_symlink(),
|
|
||||||
data.is_file(),
|
|
||||||
depth,
|
|
||||||
walk_data,
|
|
||||||
);
|
|
||||||
|
|
||||||
prog_data.num_files.fetch_add(1, ORDERING);
|
|
||||||
if let Some(ref file) = node {
|
|
||||||
prog_data.total_file_size.fetch_add(file.size, ORDERING);
|
|
||||||
}
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(ref failed) => {
|
Err(ref failed) => {
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ fn get_pretty_name(
|
|||||||
.ls_colors
|
.ls_colors
|
||||||
.style_for_path_with_metadata(&node.name, meta_result.as_ref().ok());
|
.style_for_path_with_metadata(&node.name, meta_result.as_ref().ok());
|
||||||
let ansi_style = directory_color
|
let ansi_style = directory_color
|
||||||
.map(Style::to_nu_ansi_term_style)
|
.map(Style::to_ansi_term_style)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let out = ansi_style.paint(name_and_padding);
|
let out = ansi_style.paint(name_and_padding);
|
||||||
format!("{out}")
|
format!("{out}")
|
||||||
@@ -439,9 +439,6 @@ pub fn get_number_format(output_str: &str) -> Option<(u64, char)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn human_readable_number(size: u64, output_str: &str) -> String {
|
pub fn human_readable_number(size: u64, output_str: &str) -> String {
|
||||||
if output_str == "count" {
|
|
||||||
return size.to_string();
|
|
||||||
};
|
|
||||||
match get_number_format(output_str) {
|
match get_number_format(output_str) {
|
||||||
Some((x, u)) => {
|
Some((x, u)) => {
|
||||||
format!("{}{}", (size / x), u)
|
format!("{}{}", (size / x), u)
|
||||||
@@ -542,13 +539,6 @@ mod tests {
|
|||||||
assert_eq!(s, "short 3 4.0K 100%");
|
assert_eq!(s, "short 3 4.0K 100%");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_machine_readable_filecount() {
|
|
||||||
assert_eq!(human_readable_number(1, "count"), "1");
|
|
||||||
assert_eq!(human_readable_number(1000, "count"), "1000");
|
|
||||||
assert_eq!(human_readable_number(1024, "count"), "1024");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_human_readable_number() {
|
fn test_human_readable_number() {
|
||||||
assert_eq!(human_readable_number(1, ""), "1B");
|
assert_eq!(human_readable_number(1, ""), "1B");
|
||||||
|
|||||||
125
src/main.rs
125
src/main.rs
@@ -22,14 +22,13 @@ use progress::PIndicator;
|
|||||||
use regex::Error;
|
use regex::Error;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::{read, read_to_string};
|
use std::fs::read_to_string;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Read;
|
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use sysinfo::System;
|
use sysinfo::{System, SystemExt};
|
||||||
use utils::canonicalize_absolute_path;
|
use utils::canonicalize_absolute_path;
|
||||||
|
|
||||||
use self::display::draw_it;
|
use self::display::draw_it;
|
||||||
@@ -128,15 +127,34 @@ fn main() {
|
|||||||
})
|
})
|
||||||
.expect("Error setting Ctrl-C handler");
|
.expect("Error setting Ctrl-C handler");
|
||||||
|
|
||||||
let target_dirs = if let Some(path) = config.get_files0_from(&options) {
|
let target_dirs = match config.get_files_from(&options) {
|
||||||
read_paths_from_source(&path, true)
|
Some(path) => {
|
||||||
} else if let Some(path) = config.get_files_from(&options) {
|
if path == "-" {
|
||||||
read_paths_from_source(&path, false)
|
let mut targets_to_add = io::stdin()
|
||||||
} else {
|
.lines()
|
||||||
match options.params {
|
.map_while(Result::ok)
|
||||||
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
|
if targets_to_add.is_empty() {
|
||||||
|
eprintln!("No input provided, defaulting to current directory");
|
||||||
|
targets_to_add.push(".".to_owned());
|
||||||
|
}
|
||||||
|
targets_to_add
|
||||||
|
} else {
|
||||||
|
// read file
|
||||||
|
match read_to_string(path) {
|
||||||
|
Ok(file_content) => file_content.lines().map(|x| x.to_string()).collect(),
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Error reading file: {e}");
|
||||||
|
vec![".".to_owned()]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => match options.params {
|
||||||
Some(ref values) => values.clone(),
|
Some(ref values) => values.clone(),
|
||||||
None => vec![".".to_owned()],
|
None => vec![".".to_owned()],
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let summarize_file_types = options.file_types;
|
let summarize_file_types = options.file_types;
|
||||||
@@ -154,7 +172,7 @@ fn main() {
|
|||||||
// 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 number_of_lines = match config.get_number_of_lines(&options) {
|
let number_of_lines = match options.number_of_lines {
|
||||||
Some(val) => val,
|
Some(val) => val,
|
||||||
None => {
|
None => {
|
||||||
if depth != usize::MAX {
|
if depth != usize::MAX {
|
||||||
@@ -289,21 +307,16 @@ fn main() {
|
|||||||
indicator.stop();
|
indicator.stop();
|
||||||
|
|
||||||
let print_errors = config.get_print_errors(&options);
|
let print_errors = config.get_print_errors(&options);
|
||||||
let final_errors = walk_data.errors.lock().unwrap();
|
print_any_errors(print_errors, walk_data.errors);
|
||||||
print_any_errors(print_errors, &final_errors);
|
|
||||||
|
|
||||||
if tree.children.is_empty() && !final_errors.file_not_found.is_empty() {
|
print_output(
|
||||||
std::process::exit(1)
|
config,
|
||||||
} else {
|
options,
|
||||||
print_output(
|
tree,
|
||||||
config,
|
walk_data.by_filecount,
|
||||||
options,
|
is_colors,
|
||||||
tree,
|
terminal_width,
|
||||||
walk_data.by_filecount,
|
)
|
||||||
is_colors,
|
|
||||||
terminal_width,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,11 +332,7 @@ fn print_output(
|
|||||||
|
|
||||||
if config.get_output_json(&options) {
|
if config.get_output_json(&options) {
|
||||||
OUTPUT_TYPE.with(|wrapped| {
|
OUTPUT_TYPE.with(|wrapped| {
|
||||||
if by_filecount {
|
wrapped.replace(output_format);
|
||||||
wrapped.replace("count".to_string());
|
|
||||||
} else {
|
|
||||||
wrapped.replace(output_format);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
println!("{}", serde_json::to_string(&tree).unwrap());
|
println!("{}", serde_json::to_string(&tree).unwrap());
|
||||||
} else {
|
} else {
|
||||||
@@ -348,7 +357,8 @@ fn print_output(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_any_errors(print_errors: bool, final_errors: &RuntimeErrors) {
|
fn print_any_errors(print_errors: bool, errors: Arc<Mutex<RuntimeErrors>>) {
|
||||||
|
let final_errors = errors.lock().unwrap();
|
||||||
if !final_errors.file_not_found.is_empty() {
|
if !final_errors.file_not_found.is_empty() {
|
||||||
let err = final_errors
|
let err = final_errors
|
||||||
.file_not_found
|
.file_not_found
|
||||||
@@ -384,53 +394,6 @@ fn print_any_errors(print_errors: bool, final_errors: &RuntimeErrors) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_paths_from_source(path: &str, null_terminated: bool) -> Vec<String> {
|
|
||||||
let from_stdin = path == "-";
|
|
||||||
|
|
||||||
let result: Result<Vec<String>, Option<String>> = (|| {
|
|
||||||
// 1) read bytes
|
|
||||||
let bytes = if from_stdin {
|
|
||||||
let mut b = Vec::new();
|
|
||||||
io::stdin().lock().read_to_end(&mut b).map_err(|_| None)?;
|
|
||||||
b
|
|
||||||
} else {
|
|
||||||
read(path).map_err(|e| Some(e.to_string()))?
|
|
||||||
};
|
|
||||||
|
|
||||||
let text = std::str::from_utf8(&bytes).map_err(|e| {
|
|
||||||
if from_stdin {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(e.to_string())
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
let items: Vec<String> = if null_terminated {
|
|
||||||
text.split('\0')
|
|
||||||
.filter(|s| !s.is_empty())
|
|
||||||
.map(str::to_owned)
|
|
||||||
.collect()
|
|
||||||
} else {
|
|
||||||
text.lines().map(str::to_owned).collect()
|
|
||||||
};
|
|
||||||
if from_stdin && items.is_empty() {
|
|
||||||
return Err(None);
|
|
||||||
}
|
|
||||||
Ok(items)
|
|
||||||
})();
|
|
||||||
|
|
||||||
match result {
|
|
||||||
Ok(v) => v,
|
|
||||||
Err(None) => {
|
|
||||||
eprintln!("No files provided, defaulting to current directory");
|
|
||||||
vec![".".to_owned()]
|
|
||||||
}
|
|
||||||
Err(Some(msg)) => {
|
|
||||||
eprintln!("Failed to read file: {msg}");
|
|
||||||
vec![".".to_owned()]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn init_rayon(stack: &Option<usize>, threads: &Option<usize>) -> rayon::ThreadPool {
|
fn init_rayon(stack: &Option<usize>, threads: &Option<usize>) -> rayon::ThreadPool {
|
||||||
let stack_size = match stack {
|
let stack_size = match stack {
|
||||||
Some(s) => Some(*s),
|
Some(s) => Some(*s),
|
||||||
@@ -440,10 +403,10 @@ fn init_rayon(stack: &Option<usize>, threads: &Option<usize>) -> rayon::ThreadPo
|
|||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let large_stack = usize::pow(1024, 3);
|
let large_stack = usize::pow(1024, 3);
|
||||||
let mut sys = System::new_all();
|
let mut s = System::new();
|
||||||
sys.refresh_memory();
|
s.refresh_memory();
|
||||||
// Larger stack size if possible to handle cases with lots of nested directories
|
// Larger stack size if possible to handle cases with lots of nested directories
|
||||||
let available = sys.available_memory();
|
let available = s.available_memory();
|
||||||
if available > (large_stack * threads.unwrap_or(1)).try_into().unwrap() {
|
if available > (large_stack * threads.unwrap_or(1)).try_into().unwrap() {
|
||||||
Some(large_stack)
|
Some(large_stack)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Binary file not shown.
@@ -1,2 +0,0 @@
|
|||||||
tests/test_dir_files_from/a_file
|
|
||||||
tests/test_dir_files_from/hello_file
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
hello
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use assert_cmd::{Command, cargo_bin_cmd};
|
use assert_cmd::Command;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::process::Output;
|
use std::process::Output;
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
@@ -61,11 +61,9 @@ fn initialize() {
|
|||||||
|
|
||||||
fn run_cmd<T: AsRef<OsStr>>(command_args: &[T]) -> Output {
|
fn run_cmd<T: AsRef<OsStr>>(command_args: &[T]) -> Output {
|
||||||
initialize();
|
initialize();
|
||||||
let mut to_run = cargo_bin_cmd!("dust");
|
let mut to_run = &mut Command::cargo_bin("dust").unwrap();
|
||||||
// Hide progress bar
|
|
||||||
to_run.arg("-P");
|
|
||||||
for p in command_args {
|
for p in command_args {
|
||||||
to_run.arg(p);
|
to_run = to_run.arg(p);
|
||||||
}
|
}
|
||||||
to_run.unwrap()
|
to_run.unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use assert_cmd::cargo_bin_cmd;
|
use assert_cmd::Command;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
@@ -9,16 +9,17 @@ use std::str;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
fn build_command<T: AsRef<OsStr>>(command_args: Vec<T>) -> String {
|
fn build_command<T: AsRef<OsStr>>(command_args: Vec<T>) -> String {
|
||||||
let mut cmd = cargo_bin_cmd!("dust");
|
let mut cmd = &mut Command::cargo_bin("dust").unwrap();
|
||||||
|
|
||||||
// Hide progress bar
|
// Hide progress bar
|
||||||
cmd.arg("-P");
|
cmd = cmd.arg("-P");
|
||||||
|
|
||||||
for p in command_args {
|
for p in command_args {
|
||||||
cmd.arg(p);
|
cmd = cmd.arg(p);
|
||||||
}
|
}
|
||||||
let finished = &cmd.unwrap();
|
let finished = &cmd.unwrap();
|
||||||
assert_eq!(str::from_utf8(&finished.stderr).unwrap(), "");
|
let stderr = str::from_utf8(&finished.stderr).unwrap();
|
||||||
|
assert_eq!(stderr, "");
|
||||||
|
|
||||||
str::from_utf8(&finished.stdout).unwrap().into()
|
str::from_utf8(&finished.stdout).unwrap().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,60 +104,10 @@ pub fn test_ignore_all_in_file() {
|
|||||||
assert!(!output.contains(".secret"));
|
assert!(!output.contains(".secret"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
pub fn test_files_from_flag_file() {
|
|
||||||
let output = build_command(vec![
|
|
||||||
"--files-from",
|
|
||||||
"tests/test_dir_files_from/files_from.txt",
|
|
||||||
]);
|
|
||||||
assert!(output.contains("a_file"));
|
|
||||||
assert!(output.contains("hello_file"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
pub fn test_files0_from_flag_file() {
|
|
||||||
let output = build_command(vec![
|
|
||||||
"--files0-from",
|
|
||||||
"tests/test_dir_files_from/files0_from.txt",
|
|
||||||
]);
|
|
||||||
assert!(output.contains("a_file"));
|
|
||||||
assert!(output.contains("hello_file"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
pub fn test_files_from_flag_stdin() {
|
|
||||||
let mut cmd = cargo_bin_cmd!("dust");
|
|
||||||
cmd.arg("-P").arg("--files-from").arg("-");
|
|
||||||
let input = b"tests/test_dir_files_from/a_file\ntests/test_dir_files_from/hello_file\n";
|
|
||||||
cmd.write_stdin(input.as_ref());
|
|
||||||
let finished = &cmd.unwrap();
|
|
||||||
let stderr = std::str::from_utf8(&finished.stderr).unwrap();
|
|
||||||
assert_eq!(stderr, "");
|
|
||||||
let output = std::str::from_utf8(&finished.stdout).unwrap();
|
|
||||||
assert!(output.contains("a_file"));
|
|
||||||
assert!(output.contains("hello_file"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
pub fn test_files0_from_flag_stdin() {
|
|
||||||
let mut cmd = cargo_bin_cmd!("dust");
|
|
||||||
cmd.arg("-P").arg("--files0-from").arg("-");
|
|
||||||
let input = b"tests/test_dir_files_from/a_file\0tests/test_dir_files_from/hello_file\0";
|
|
||||||
cmd.write_stdin(input.as_ref());
|
|
||||||
let finished = &cmd.unwrap();
|
|
||||||
let stderr = std::str::from_utf8(&finished.stderr).unwrap();
|
|
||||||
assert_eq!(stderr, "");
|
|
||||||
let output = std::str::from_utf8(&finished.stdout).unwrap();
|
|
||||||
assert!(output.contains("a_file"));
|
|
||||||
assert!(output.contains("hello_file"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_with_bad_param() {
|
pub fn test_with_bad_param() {
|
||||||
let mut cmd = cargo_bin_cmd!("dust");
|
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||||
cmd.arg("-P").arg("bad_place");
|
let result = cmd.arg("bad_place").unwrap();
|
||||||
let output_error = cmd.unwrap_err();
|
|
||||||
let result = output_error.as_output().unwrap();
|
|
||||||
let stderr = str::from_utf8(&result.stderr).unwrap();
|
let stderr = str::from_utf8(&result.stderr).unwrap();
|
||||||
assert!(stderr.contains("No such file or directory"));
|
assert!(stderr.contains("No such file or directory"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use assert_cmd::{Command, cargo_bin_cmd};
|
use assert_cmd::Command;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -44,7 +44,7 @@ pub fn test_soft_sym_link() {
|
|||||||
let b = format!(" ┌── {}", file_path_s);
|
let b = format!(" ┌── {}", file_path_s);
|
||||||
let a = format!("─┴ {}", dir_s);
|
let a = format!("─┴ {}", dir_s);
|
||||||
|
|
||||||
let mut cmd = cargo_bin_cmd!("dust");
|
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||||
// Mac test runners create long filenames in tmp directories
|
// Mac test runners create long filenames in tmp directories
|
||||||
let output = cmd
|
let output = cmd
|
||||||
.args(["-p", "-c", "-s", "-w", "999", dir_s])
|
.args(["-p", "-c", "-s", "-w", "999", dir_s])
|
||||||
@@ -72,7 +72,7 @@ pub fn test_hard_sym_link() {
|
|||||||
let file_output = format!(" ┌── {}", file_path_s);
|
let file_output = format!(" ┌── {}", file_path_s);
|
||||||
let dirs_output = format!("─┴ {}", dir_s);
|
let dirs_output = format!("─┴ {}", dir_s);
|
||||||
|
|
||||||
let mut cmd = cargo_bin_cmd!("dust");
|
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||||
// Mac test runners create long filenames in tmp directories
|
// Mac test runners create long filenames in tmp directories
|
||||||
let output = cmd.args(["-p", "-c", "-w", "999", dir_s]).unwrap().stdout;
|
let output = cmd.args(["-p", "-c", "-w", "999", dir_s]).unwrap().stdout;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ pub fn test_hard_sym_link_no_dup_multi_arg() {
|
|||||||
let link_name = dir_link.path().join("the_link");
|
let link_name = dir_link.path().join("the_link");
|
||||||
let link_name_s = link_it(link_name, file_path_s, false);
|
let link_name_s = link_it(link_name, file_path_s, false);
|
||||||
|
|
||||||
let mut cmd = cargo_bin_cmd!("dust");
|
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||||
|
|
||||||
// Mac test runners create long filenames in tmp directories
|
// Mac test runners create long filenames in tmp directories
|
||||||
let output = cmd
|
let output = cmd
|
||||||
@@ -123,7 +123,7 @@ pub fn test_recursive_sym_link() {
|
|||||||
let a = format!("─┬ {}", dir_s);
|
let a = format!("─┬ {}", dir_s);
|
||||||
let b = format!(" └── {}", link_name_s);
|
let b = format!(" └── {}", link_name_s);
|
||||||
|
|
||||||
let mut cmd = cargo_bin_cmd!("dust");
|
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||||
let output = cmd
|
let output = cmd
|
||||||
.arg("-p")
|
.arg("-p")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
|
|||||||
Reference in New Issue
Block a user