mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fabe19b8de | |||
| 2066b7fa86 | |||
| 07be4261b9 | |||
| d26971f869 | |||
| 28018bc8c2 | |||
| 37dd671e5e | |||
| d39224d670 | |||
| 6c20fae3e8 | |||
| 3ab81fcd2f | |||
| 0703784cab | |||
| f51bd0d6a3 | |||
| 514bdcdc74 | |||
| 4b64585290 | |||
| 10eba445c9 | |||
| a0c0779849 | |||
| 62bf1e14de | |||
| de2d748a88 | |||
| 509d51e872 | |||
| f98b841d23 | |||
| 67d23e80ff | |||
| 968377eebd |
Generated
+282
-359
File diff suppressed because it is too large
Load Diff
+8
-9
@@ -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.4"
|
||||||
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"
|
||||||
@@ -27,11 +27,11 @@ lto = true
|
|||||||
strip = true
|
strip = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ansi_term = "0.12"
|
clap = { version = "4", features = ["derive"] }
|
||||||
clap = { version = "4.4", features = ["derive"] }
|
lscolors = "0.21"
|
||||||
lscolors = "0.13"
|
nu-ansi-term = "0.50"
|
||||||
terminal_size = "0.2"
|
terminal_size = "0.4"
|
||||||
unicode-width = "0.1"
|
unicode-width = "0.2"
|
||||||
rayon = "1"
|
rayon = "1"
|
||||||
thousands = "0.2"
|
thousands = "0.2"
|
||||||
stfu8 = "0.2"
|
stfu8 = "0.2"
|
||||||
@@ -39,9 +39,8 @@ 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"
|
||||||
directories = "4"
|
sysinfo = "0.37"
|
||||||
sysinfo = "0.27"
|
ctrlc = "3"
|
||||||
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]
|
||||||
|
|||||||
@@ -13,6 +13,17 @@ Because I want an easy way to see where my disk is being used.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
Study the above picture.
|
||||||
|
|
||||||
|
* We see `target` has 1.8G
|
||||||
|
* `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.2G - Note the bar jumps down to 70% to indicate 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 indicate the file is small.
|
||||||
|
|
||||||
|
From here we can conclude:
|
||||||
|
* `target/debug/deps` takes the majority 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>
|
||||||
@@ -69,6 +80,8 @@ 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
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -125,4 +138,14 @@ reverse=true
|
|||||||
- [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`
|
||||||
|
|
||||||
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.
|
## 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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -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+[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER:_default' \
|
'-n+[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' \
|
'--number-of-lines=[Display the '\''n'\'' largest entries. (Default is terminal_height)]: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' \
|
||||||
|
|||||||
@@ -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, 'Number of lines of output to show. (Default is terminal_height - 10)')
|
[CompletionResult]::new('-n', '-n', [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('--number-of-lines', '--number-of-lines', [CompletionResultType]::ParameterName, 'Display the ''n'' largest entries. (Default is terminal_height)')
|
||||||
[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')
|
||||||
|
|||||||
@@ -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 'Number of lines of output to show. (Default is terminal_height - 10)'
|
cand -n '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 --number-of-lines 'Display the ''n'' largest entries. (Default is terminal_height)'
|
||||||
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'
|
||||||
|
|||||||
@@ -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 'Number of lines of output to show. (Default is terminal_height - 10)' -r
|
complete -c dust -s n -l number-of-lines -d 'Display the \'n\' largest entries. (Default is terminal_height)' -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
|
||||||
|
|||||||
@@ -28,3 +28,6 @@ ignore-hidden=true
|
|||||||
output-format="si"
|
output-format="si"
|
||||||
|
|
||||||
number-of-lines=5
|
number-of-lines=5
|
||||||
|
|
||||||
|
# To keep the .git directory collapsed
|
||||||
|
collapse=[".git"]
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
.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.4"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Dust \- Like du but more intuitive
|
Dust \- Like du but more intuitive
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -19,7 +19,7 @@ Number of threads to use
|
|||||||
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 \fI<NUMBER>\fR
|
||||||
Number of lines of output to show. (Default is terminal_height \- 10)
|
Display the \*(Aqn\*(Aq largest entries. (Default is terminal_height)
|
||||||
.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
|
||||||
@@ -170,4 +170,4 @@ Print version
|
|||||||
[\fIPATH\fR]
|
[\fIPATH\fR]
|
||||||
Input files or directories
|
Input files or directories
|
||||||
.SH VERSION
|
.SH VERSION
|
||||||
v1.2.3
|
v1.2.4
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 107 KiB |
+1
-1
@@ -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>,
|
||||||
|
|
||||||
/// Number of lines of output to show. (Default is terminal_height - 10)
|
/// Display the 'n' largest entries. (Default is terminal_height)
|
||||||
#[arg(short, long, value_name("NUMBER"))]
|
#[arg(short, long, value_name("NUMBER"))]
|
||||||
pub number_of_lines: Option<usize>,
|
pub number_of_lines: Option<usize>,
|
||||||
|
|
||||||
|
|||||||
+12
-3
@@ -38,6 +38,7 @@ pub struct Config {
|
|||||||
pub files0_from: Option<String>,
|
pub files0_from: Option<String>,
|
||||||
pub number_of_lines: Option<usize>,
|
pub number_of_lines: Option<usize>,
|
||||||
pub files_from: Option<String>,
|
pub files_from: Option<String>,
|
||||||
|
pub collapse: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@@ -177,6 +178,14 @@ impl Config {
|
|||||||
pub fn get_changed_time_operator(&self, options: &Cli) -> Option<(Operator, i64)> {
|
pub fn get_changed_time_operator(&self, options: &Cli) -> Option<(Operator, i64)> {
|
||||||
get_filter_time_operator(options.ctime.as_ref(), get_current_date_epoch_seconds())
|
get_filter_time_operator(options.ctime.as_ref(), get_current_date_epoch_seconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_collapse(&self, options: &Cli) -> Option<Vec<String>> {
|
||||||
|
if self.collapse.is_none() {
|
||||||
|
options.collapse.clone()
|
||||||
|
} else {
|
||||||
|
self.collapse.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_current_date_epoch_seconds() -> i64 {
|
fn get_current_date_epoch_seconds() -> i64 {
|
||||||
@@ -244,7 +253,7 @@ fn convert_min_size(input: &str) -> Option<usize> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_config_locations(base: &Path) -> Vec<PathBuf> {
|
fn get_config_locations(base: PathBuf) -> 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,8 +276,8 @@ pub fn get_config(conf_path: Option<&String>) -> Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if let Some(home) = directories::BaseDirs::new() {
|
if let Some(home) = std::env::home_dir() {
|
||||||
for path in get_config_locations(home.home_dir()) {
|
for path in get_config_locations(home) {
|
||||||
if path.exists()
|
if path.exists()
|
||||||
&& let Ok(config) = Config::from_config_file(&path)
|
&& let Ok(config) = Config::from_config_file(&path)
|
||||||
{
|
{
|
||||||
|
|||||||
+12
-2
@@ -1,8 +1,8 @@
|
|||||||
use crate::display_node::DisplayNode;
|
use crate::display_node::DisplayNode;
|
||||||
use crate::node::FileTime;
|
use crate::node::FileTime;
|
||||||
|
|
||||||
use ansi_term::Colour::Red;
|
|
||||||
use lscolors::{LsColors, Style};
|
use lscolors::{LsColors, Style};
|
||||||
|
use nu_ansi_term::Color::Red;
|
||||||
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
@@ -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_ansi_term_style)
|
.map(Style::to_nu_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,6 +439,9 @@ 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)
|
||||||
@@ -539,6 +542,13 @@ 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");
|
||||||
|
|||||||
+11
-7
@@ -29,7 +29,7 @@ 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, SystemExt};
|
use sysinfo::System;
|
||||||
use utils::canonicalize_absolute_path;
|
use utils::canonicalize_absolute_path;
|
||||||
|
|
||||||
use self::display::draw_it;
|
use self::display::draw_it;
|
||||||
@@ -69,7 +69,7 @@ fn should_init_color(no_color: bool, force_color: bool) -> bool {
|
|||||||
{
|
{
|
||||||
// Required for windows 10
|
// Required for windows 10
|
||||||
// Fails to resolve for windows 8 so disable color
|
// Fails to resolve for windows 8 so disable color
|
||||||
match ansi_term::enable_ansi_support() {
|
match nu_ansi_term::enable_ansi_support() {
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
eprintln!("This version of Windows does not support ANSI colors");
|
eprintln!("This version of Windows does not support ANSI colors");
|
||||||
@@ -224,7 +224,7 @@ fn main() {
|
|||||||
indicator.spawn(output_format.clone())
|
indicator.spawn(output_format.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
let keep_collapsed: HashSet<PathBuf> = match options.collapse {
|
let keep_collapsed: HashSet<PathBuf> = match config.get_collapse(&options) {
|
||||||
Some(ref collapse) => {
|
Some(ref collapse) => {
|
||||||
let mut combined_dirs = HashSet::new();
|
let mut combined_dirs = HashSet::new();
|
||||||
for collapse_dir in collapse {
|
for collapse_dir in collapse {
|
||||||
@@ -319,7 +319,11 @@ fn print_output(
|
|||||||
|
|
||||||
if config.get_output_json(&options) {
|
if config.get_output_json(&options) {
|
||||||
OUTPUT_TYPE.with(|wrapped| {
|
OUTPUT_TYPE.with(|wrapped| {
|
||||||
wrapped.replace(output_format);
|
if by_filecount {
|
||||||
|
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 {
|
||||||
@@ -436,10 +440,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 s = System::new();
|
let mut sys = System::new_all();
|
||||||
s.refresh_memory();
|
sys.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 = s.available_memory();
|
let available = sys.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 {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use assert_cmd::Command;
|
use assert_cmd::{Command, cargo_bin_cmd};
|
||||||
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,9 +61,11 @@ 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 = &mut Command::cargo_bin("dust").unwrap();
|
let mut to_run = cargo_bin_cmd!("dust");
|
||||||
|
// Hide progress bar
|
||||||
|
to_run.arg("-P");
|
||||||
for p in command_args {
|
for p in command_args {
|
||||||
to_run = to_run.arg(p);
|
to_run.arg(p);
|
||||||
}
|
}
|
||||||
to_run.unwrap()
|
to_run.unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-10
@@ -1,4 +1,4 @@
|
|||||||
use assert_cmd::Command;
|
use assert_cmd::cargo_bin_cmd;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
@@ -9,17 +9,16 @@ 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 = &mut Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
|
|
||||||
// Hide progress bar
|
// Hide progress bar
|
||||||
cmd = cmd.arg("-P");
|
cmd.arg("-P");
|
||||||
|
|
||||||
for p in command_args {
|
for p in command_args {
|
||||||
cmd = cmd.arg(p);
|
cmd.arg(p);
|
||||||
}
|
}
|
||||||
let finished = &cmd.unwrap();
|
let finished = &cmd.unwrap();
|
||||||
let stderr = str::from_utf8(&finished.stderr).unwrap();
|
assert_eq!(str::from_utf8(&finished.stderr).unwrap(), "");
|
||||||
assert_eq!(stderr, "");
|
|
||||||
|
|
||||||
str::from_utf8(&finished.stdout).unwrap().into()
|
str::from_utf8(&finished.stdout).unwrap().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +125,7 @@ pub fn test_files0_from_flag_file() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_files_from_flag_stdin() {
|
pub fn test_files_from_flag_stdin() {
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
cmd.arg("-P").arg("--files-from").arg("-");
|
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";
|
let input = b"tests/test_dir_files_from/a_file\ntests/test_dir_files_from/hello_file\n";
|
||||||
cmd.write_stdin(input.as_ref());
|
cmd.write_stdin(input.as_ref());
|
||||||
@@ -140,7 +139,7 @@ pub fn test_files_from_flag_stdin() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_files0_from_flag_stdin() {
|
pub fn test_files0_from_flag_stdin() {
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
cmd.arg("-P").arg("--files0-from").arg("-");
|
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";
|
let input = b"tests/test_dir_files_from/a_file\0tests/test_dir_files_from/hello_file\0";
|
||||||
cmd.write_stdin(input.as_ref());
|
cmd.write_stdin(input.as_ref());
|
||||||
@@ -154,7 +153,7 @@ pub fn test_files0_from_flag_stdin() {
|
|||||||
|
|
||||||
#[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 = cargo_bin_cmd!("dust");
|
||||||
cmd.arg("-P").arg("bad_place");
|
cmd.arg("-P").arg("bad_place");
|
||||||
let output_error = cmd.unwrap_err();
|
let output_error = cmd.unwrap_err();
|
||||||
let result = output_error.as_output().unwrap();
|
let result = output_error.as_output().unwrap();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use assert_cmd::Command;
|
use assert_cmd::{Command, cargo_bin_cmd};
|
||||||
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 = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
// 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 = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
// 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 = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
|
|
||||||
// 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 = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
let output = cmd
|
let output = cmd
|
||||||
.arg("-p")
|
.arg("-p")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
|
|||||||
Reference in New Issue
Block a user