Compare commits

..

2 Commits

Author SHA1 Message Date
andy.boot d00519085a style: fix clippy 2025-10-06 20:31:20 +01:00
andy.boot 04b80b474c deps: cargo update 2025-10-06 20:28:41 +01:00
5 changed files with 66 additions and 20 deletions
Generated
+61 -2
View File
@@ -289,6 +289,26 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
[[package]]
name = "directories"
version = "4.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]] [[package]]
name = "dispatch" name = "dispatch"
version = "0.2.0" version = "0.2.0"
@@ -313,6 +333,7 @@ dependencies = [
"clap_mangen", "clap_mangen",
"config-file", "config-file",
"ctrlc", "ctrlc",
"directories",
"filesize", "filesize",
"lscolors", "lscolors",
"portable-atomic", "portable-atomic",
@@ -366,6 +387,17 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3" checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3"
[[package]]
name = "getrandom"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
dependencies = [
"cfg-if",
"libc",
"wasi 0.11.1+wasi-snapshot-preview1",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.3.3" version = "0.3.3"
@@ -375,7 +407,7 @@ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"r-efi", "r-efi",
"wasi", "wasi 0.14.7+wasi-0.2.4",
] ]
[[package]] [[package]]
@@ -453,6 +485,16 @@ version = "0.2.176"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174"
[[package]]
name = "libredox"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb"
dependencies = [
"bitflags 2.9.4",
"libc",
]
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.3.8" version = "0.3.8"
@@ -622,6 +664,17 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "redox_users"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
dependencies = [
"getrandom 0.2.16",
"libredox",
"thiserror",
]
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.11.3" version = "1.11.3"
@@ -790,7 +843,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
dependencies = [ dependencies = [
"fastrand", "fastrand",
"getrandom", "getrandom 0.3.3",
"once_cell", "once_cell",
"rustix 1.1.2", "rustix 1.1.2",
"windows-sys 0.61.1", "windows-sys 0.61.1",
@@ -874,6 +927,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "wasi"
version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.14.7+wasi-0.2.4" version = "0.14.7+wasi-0.2.4"
+1
View File
@@ -39,6 +39,7 @@ 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.27" sysinfo = "0.27"
ctrlc = "3.4" ctrlc = "3.4"
chrono = "0.4" chrono = "0.4"
+3 -3
View File
@@ -244,7 +244,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,8 +267,8 @@ 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) && let Ok(config) = Config::from_config_file(&path)
{ {
-10
View File
@@ -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");
-4
View File
@@ -319,11 +319,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("count".to_string());
} else {
wrapped.replace(output_format); wrapped.replace(output_format);
}
}); });
println!("{}", serde_json::to_string(&tree).unwrap()); println!("{}", serde_json::to_string(&tree).unwrap());
} else { } else {