From a3f18d271d4c4fd8308b63967181396f36e77ae8 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Wed, 17 Jul 2019 10:48:22 +0200 Subject: [PATCH] Support for adding data from command line --- src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 59c8e5a..5d3837e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::env::var; +use std::env::{args, var}; use std::fs::File; use std::io::Read; @@ -20,7 +20,7 @@ pub fn main() { let kernel = format!("{style}Kernel:{unstyle} {}", kernel().unwrap(), style = style, unstyle = unstyle); let uptime = format!("{style}Uptime:{unstyle} {}", &uptime().unwrap()[3..], style = style, unstyle = unstyle); - let info = [ + let mut info = vec![ String::from("\n"), username, osname, @@ -28,6 +28,15 @@ pub fn main() { uptime, ]; + for arg in args().skip(1) { + let split = arg.split(":").collect::>(); + if split.len() != 2 { + eprintln!("\x1B[33;1mwarning:\x1B[0m argument must be formatted like \"key:value\""); + continue; + } + info.push(format!("{style}{}:{unstyle} {}\n", split[0], split[1], style = style, unstyle = unstyle)); + } + let mut logo_iterator = Os::ArchLinux.ascii_logo().lines(); let mut info_iterator = info.iter();