Changed the formatting of uptime

This commit is contained in:
River 2023-01-04 23:43:19 -05:00
parent 0d8cb2dba2
commit bf9ab67333
3 changed files with 13 additions and 4 deletions

7
Cargo.lock generated
View File

@ -82,6 +82,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "compound_duration"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c803d816c4ed6d0dadd5b54f7ef4f3761418fe802106b161d77476cc3c664c"
[[package]]
name = "core-foundation-sys"
version = "0.8.3"
@ -321,6 +327,7 @@ version = "0.1.0"
dependencies = [
"chrono",
"colored",
"compound_duration",
"quoted-string",
"sysinfo",
"whoami",

View File

@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
chrono = "0.4.23"
colored = "2.0.0"
compound_duration = "1.2.0"
quoted-string = "0.6.1"
sysinfo = "0.27.2"
whoami = "1.3.0"
whoami = "1.3.0"

View File

@ -4,6 +4,7 @@ use colored::*;
use sysinfo::*;
use std::env;
use whoami;
use compound_duration;
fn main() {
let sys_info = InformationStruct::new();
@ -21,7 +22,7 @@ fn main() {
color_print("OS:\t", sys_info.icon, &sys_info.os_name, &sys_info.color);
color_print("Ver:\t", '', &sys_info.os_ver, "bright red");
color_print("Kernel:\t", '', &sys_info.kernel_ver, "bright blue");
color_print("Uptime:\t", '', &Some(format!("{}s", sys_info.uptime)), "bright black");
color_print("Uptime:\t", '', &Some(sys_info.uptime), "bright black");
color_print("Shell:\t", '', &sys_info.shell, "bright magenta");
color_print("CPU:\t", '', &Some(sys_info.cpu), "green");
color_print("GPU:\t", '', &sys_info.gpu, "bright green")
@ -42,7 +43,7 @@ struct InformationStruct {
os_name: Option<String>,
os_ver: Option<String>,
kernel_ver: Option<String>,
uptime: u64,
uptime: String,
shell: Option<String>,
_terminal: String,
cpu: String,
@ -67,7 +68,7 @@ impl InformationStruct {
kernel_ver: sys.kernel_version(),
uptime: sys.uptime(),
uptime: compound_duration::format_dhms(sys.uptime()),
shell: {
let var = env::var("SHELL");