mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8be6b2d9cd | |||
| 509d51e872 | |||
| f98b841d23 | |||
| 67d23e80ff | |||
| 968377eebd |
Generated
+2
-61
@@ -289,26 +289,6 @@ 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"
|
||||||
@@ -333,7 +313,6 @@ dependencies = [
|
|||||||
"clap_mangen",
|
"clap_mangen",
|
||||||
"config-file",
|
"config-file",
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"directories",
|
|
||||||
"filesize",
|
"filesize",
|
||||||
"lscolors",
|
"lscolors",
|
||||||
"portable-atomic",
|
"portable-atomic",
|
||||||
@@ -387,17 +366,6 @@ 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"
|
||||||
@@ -407,7 +375,7 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"r-efi",
|
"r-efi",
|
||||||
"wasi 0.14.7+wasi-0.2.4",
|
"wasi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -485,16 +453,6 @@ 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"
|
||||||
@@ -664,17 +622,6 @@ 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"
|
||||||
@@ -843,7 +790,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
|
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"getrandom 0.3.3",
|
"getrandom",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix 1.1.2",
|
"rustix 1.1.2",
|
||||||
"windows-sys 0.61.1",
|
"windows-sys 0.61.1",
|
||||||
@@ -927,12 +874,6 @@ 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"
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ 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
@@ -244,7 +244,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 +267,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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
+5
-1
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user