Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

du cleanup #5623

Merged
merged 4 commits into from
Dec 8, 2023
Merged

du cleanup #5623

merged 4 commits into from
Dec 8, 2023

Conversation

tertsdiepraam
Copy link
Member

Related to: nushell/nushell#11040 (comment)

Just some general cleanup of du:

  • Merging imports
  • Not keeping the clap ArgMatches around but put everything in the options structs
  • Split options into traversal en printing options
  • Format sizes without keeping function pointers around

There's more to do, but it's a start :)

Copy link

github-actions bot commented Dec 7, 2023

GNU testsuite comparison:

Congrats! The gnu test tests/tail/inotify-dir-recreate is no longer failing!

convert_size,
})
fn new(options: PrintingOptions, summarize: bool) -> UResult<Self> {
Ok(Self { summarize, options })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ok(Self { summarize, options })
Ok(Self { options, summarize })

Comment on lines 562 to 570
for &(unit, power) in &UNITS {
let limit = multiplier.pow(power);
if size >= limit {
return format!("{:.1}{}", (size as f64) / (limit as f64), unit);
}
}
if size == 0 {
return "0".to_string();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for &(unit, power) in &UNITS {
let limit = multiplier.pow(power);
if size >= limit {
return format!("{:.1}{}", (size as f64) / (limit as f64), unit);
}
}
if size == 0 {
return "0".to_string();
}
if size == 0 {
return "0".to_string();
}
for &(unit, power) in &UNITS {
let limit = multiplier.pow(power);
if size >= limit {
return format!("{:.1}{}", (size as f64) / (limit as f64), unit);
}
}

Copy link
Contributor

@cakebaker cakebaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for getting rid of those convert_size_* functions.

@cakebaker cakebaker merged commit 7695fe3 into uutils:main Dec 8, 2023
60 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants