Skip to content

Commit 3f19e07

Browse files
committed
top: pass scale-summary-mem instead of args to summary
1 parent 5093892 commit 3f19e07

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/uu/top/src/header.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
use crate::picker::{sysinfo, systemstat};
77
use bytesize::ByteSize;
8-
use clap::ArgMatches;
98
use systemstat::Platform;
109

11-
pub(crate) fn header(arg: &ArgMatches) -> String {
10+
pub(crate) fn header(scale_summary_mem: Option<&String>) -> String {
1211
format!(
1312
"top - {time} {uptime}, {user}, {load_average}\n\
1413
{task}\n\
@@ -20,7 +19,7 @@ pub(crate) fn header(arg: &ArgMatches) -> String {
2019
load_average = load_average(),
2120
task = task(),
2221
cpu = cpu(),
23-
memory = memory(arg),
22+
memory = memory(scale_summary_mem),
2423
)
2524
}
2625

@@ -331,9 +330,9 @@ fn cpu() -> String {
331330
todo()
332331
}
333332

334-
fn memory(arg: &ArgMatches) -> String {
333+
fn memory(scale_summary_mem: Option<&String>) -> String {
335334
let binding = sysinfo().read().unwrap();
336-
let (unit, unit_name) = match arg.get_one::<String>("scale-summary-mem") {
335+
let (unit, unit_name) = match scale_summary_mem {
337336
Some(scale) => match scale.as_str() {
338337
"k" => (bytesize::KIB, "KiB"),
339338
"m" => (bytesize::MIB, "MiB"),

src/uu/top/src/top.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
9999
table
100100
};
101101

102-
println!("{}", header(&matches));
102+
println!("{}", header(matches.get_one::<String>("scale-summary-mem")));
103103
println!("\n");
104104

105105
let cutter = {

0 commit comments

Comments
 (0)