Skip to content

Commit cfb3486

Browse files
author
梶塚太智
committed
Update main.rs
Append option `mem-size` of command `sys-info`
1 parent 4ae385b commit cfb3486

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::io::{self, Error, Read, Write};
88
use std::path::Path;
99
use std::thread::{self, sleep};
1010
use std::time::{Duration, SystemTime, UNIX_EPOCH};
11-
use sys_info::{cpu_num, cpu_speed, hostname, os_release, os_type};
11+
use sys_info::{cpu_num, cpu_speed, hostname, mem_info, os_release, os_type};
1212

1313
#[cfg(test)]
1414
mod test;
@@ -1130,6 +1130,10 @@ impl Executor {
11301130
"cpu-num" => Type::Number(cpu_num().unwrap_or(0) as f64),
11311131
"cpu-speed" => Type::Number(cpu_speed().unwrap_or(0) as f64),
11321132
"host-name" => Type::String(hostname().unwrap_or("".to_string())),
1133+
"mem-size" => match mem_info() {
1134+
Ok(info) => Type::Number(info.total as f64),
1135+
Err(_) => Type::Error("sys-info".to_string()),
1136+
},
11331137
_ => Type::Error("sys-info".to_string()),
11341138
})
11351139
}

0 commit comments

Comments
 (0)