Compare commits

...

4 Commits

Author SHA1 Message Date
andy.boot
abea47f490 tests: Update assert_cmd
Use new cargo_bin_cmd macro. Old way of building Commands is deprecated
2025-11-24 21:18:36 +00:00
andy.boot
62bf1e14de deps: update libraries 2025-11-24 21:15:44 +00:00
andy.boot
de2d748a88 chore: Retire directories library
Only used in one place (less dependencies = good).
Also directories has been retired as a github project. Easier to replace
with std::env::home() which has all the functionality we need
2025-11-20 23:46:34 +00:00
Benjamin A. Beasley
509d51e872 Update directories from 4 to 6 2025-11-20 22:46:40 +00:00
8 changed files with 290 additions and 358 deletions

582
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -28,10 +28,10 @@ strip = true
[dependencies]
ansi_term = "0.12"
clap = { version = "4.4", features = ["derive"] }
lscolors = "0.13"
terminal_size = "0.2"
unicode-width = "0.1"
clap = { version = "4", features = ["derive"] }
lscolors = "0.21"
terminal_size = "0.4"
unicode-width = "0.2"
rayon = "1"
thousands = "0.2"
stfu8 = "0.2"
@@ -39,9 +39,8 @@ regex = "1"
config-file = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
directories = "4"
sysinfo = "0.27"
ctrlc = "3.4"
sysinfo = "0.37"
ctrlc = "3"
chrono = "0.4"
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]

View File

@@ -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![
base.join(".dust.toml"),
base.join(".config").join("dust").join("config.toml"),
@@ -267,8 +267,8 @@ pub fn get_config(conf_path: Option<&String>) -> Config {
}
}
None => {
if let Some(home) = directories::BaseDirs::new() {
for path in get_config_locations(home.home_dir()) {
if let Some(home) = std::env::home_dir() {
for path in get_config_locations(home) {
if path.exists()
&& let Ok(config) = Config::from_config_file(&path)
{

View File

@@ -403,7 +403,7 @@ fn get_pretty_name(
.ls_colors
.style_for_path_with_metadata(&node.name, meta_result.as_ref().ok());
let ansi_style = directory_color
.map(Style::to_ansi_term_style)
.map(Style::to_nu_ansi_term_style)
.unwrap_or_default();
let out = ansi_style.paint(name_and_padding);
format!("{out}")

View File

@@ -29,7 +29,7 @@ use std::panic;
use std::process;
use std::sync::Arc;
use std::sync::Mutex;
use sysinfo::{System, SystemExt};
use sysinfo::System;
use utils::canonicalize_absolute_path;
use self::display::draw_it;
@@ -440,10 +440,10 @@ fn init_rayon(stack: &Option<usize>, threads: &Option<usize>) -> rayon::ThreadPo
None
} else {
let large_stack = usize::pow(1024, 3);
let mut s = System::new();
s.refresh_memory();
let mut sys = System::new_all();
sys.refresh_memory();
// 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() {
Some(large_stack)
} else {

View File

@@ -1,4 +1,4 @@
use assert_cmd::Command;
use assert_cmd::{Command, cargo_bin_cmd};
use std::ffi::OsStr;
use std::process::Output;
use std::sync::Once;
@@ -61,9 +61,11 @@ fn initialize() {
fn run_cmd<T: AsRef<OsStr>>(command_args: &[T]) -> Output {
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 {
to_run = to_run.arg(p);
to_run.arg(p);
}
to_run.unwrap()
}

View File

@@ -1,4 +1,4 @@
use assert_cmd::Command;
use assert_cmd::cargo_bin_cmd;
use std::ffi::OsStr;
use std::str;
@@ -9,17 +9,16 @@ use std::str;
*/
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
cmd = cmd.arg("-P");
cmd.arg("-P");
for p in command_args {
cmd = cmd.arg(p);
cmd.arg(p);
}
let finished = &cmd.unwrap();
let stderr = str::from_utf8(&finished.stderr).unwrap();
assert_eq!(stderr, "");
assert_eq!(str::from_utf8(&finished.stderr).unwrap(), "");
str::from_utf8(&finished.stdout).unwrap().into()
}
@@ -126,7 +125,7 @@ pub fn test_files0_from_flag_file() {
#[test]
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("-");
let input = b"tests/test_dir_files_from/a_file\ntests/test_dir_files_from/hello_file\n";
cmd.write_stdin(input.as_ref());
@@ -140,7 +139,7 @@ pub fn test_files_from_flag_stdin() {
#[test]
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("-");
let input = b"tests/test_dir_files_from/a_file\0tests/test_dir_files_from/hello_file\0";
cmd.write_stdin(input.as_ref());
@@ -154,7 +153,7 @@ pub fn test_files0_from_flag_stdin() {
#[test]
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");
let output_error = cmd.unwrap_err();
let result = output_error.as_output().unwrap();

View File

@@ -1,4 +1,4 @@
use assert_cmd::Command;
use assert_cmd::{Command, cargo_bin_cmd};
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
@@ -44,7 +44,7 @@ pub fn test_soft_sym_link() {
let b = format!(" ┌── {}", file_path_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
let output = cmd
.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 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
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_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
let output = cmd
@@ -123,7 +123,7 @@ pub fn test_recursive_sym_link() {
let a = format!("─┬ {}", dir_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
.arg("-p")
.arg("-c")