From 09999427ccfb822918fc6969e16d0fc656087ff1 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 7 Dec 2023 10:02:29 +0100 Subject: [PATCH 1/4] du: merge imports --- src/uu/du/src/du.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index dc03a64f218..989e663e46c 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -3,35 +3,30 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use chrono::prelude::DateTime; -use chrono::Local; -use clap::ArgAction; -use clap::{crate_version, Arg, ArgMatches, Command}; +use chrono::{DateTime, Local}; +use clap::{crate_version, Arg, ArgAction, ArgMatches, Command}; use glob::Pattern; use std::collections::HashSet; use std::env; -use std::fs; -use std::fs::File; +use std::error::Error; +use std::fmt::Display; #[cfg(not(windows))] use std::fs::Metadata; -use std::io::BufRead; -use std::io::BufReader; +use std::fs::{self, File}; +use std::io::{BufRead, BufReader}; #[cfg(not(windows))] use std::os::unix::fs::MetadataExt; #[cfg(windows)] use std::os::windows::fs::MetadataExt; #[cfg(windows)] use std::os::windows::io::AsRawHandle; -use std::path::Path; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::mpsc; use std::thread; use std::time::{Duration, UNIX_EPOCH}; -use std::{error::Error, fmt::Display}; use uucore::display::{print_verbatim, Quotable}; -use uucore::error::FromIo; -use uucore::error::{UError, UResult, USimpleError}; +use uucore::error::{FromIo, UError, UResult, USimpleError}; use uucore::line_ending::LineEnding; use uucore::parse_glob; use uucore::parse_size::{parse_size_u64, ParseSizeError}; From 6cae19156926ef0ca68e1e3657dd51e2066d4e8b Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 7 Dec 2023 11:06:04 +0100 Subject: [PATCH 2/4] du: remove ArgMatches from StatPrinter --- src/uu/du/src/du.rs | 165 ++++++++++++++++++++++---------------------- 1 file changed, 84 insertions(+), 81 deletions(-) diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 989e663e46c..26e697abb46 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -87,6 +87,18 @@ struct Options { count_links: bool, inodes: bool, verbose: bool, + threshold: Option, + apparent_size: bool, + // TODO: the size conversion fields should be unified + si: bool, + bytes: bool, + human_readable: bool, + block_size_1k: bool, + block_size_1m: bool, + block_size: u64, + time: Option