-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
du
cleanup
#5623
Conversation
GNU testsuite comparison:
|
src/uu/du/src/du.rs
Outdated
convert_size, | ||
}) | ||
fn new(options: PrintingOptions, summarize: bool) -> UResult<Self> { | ||
Ok(Self { summarize, options }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok(Self { summarize, options }) | |
Ok(Self { options, summarize }) |
src/uu/du/src/du.rs
Outdated
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(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); | |
} | |
} |
There was a problem hiding this 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.
7cc73b0
to
7861559
Compare
Related to: nushell/nushell#11040 (comment)
Just some general cleanup of
du
:ArgMatches
around but put everything in the options structsThere's more to do, but it's a start :)