Support for adding data from command line

This commit is contained in:
Thomas Forgione 2019-07-17 10:48:22 +02:00
parent bf3114d1e0
commit a3f18d271d
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
use std::env::var; use std::env::{args, var};
use std::fs::File; use std::fs::File;
use std::io::Read; use std::io::Read;
@ -20,7 +20,7 @@ pub fn main() {
let kernel = format!("{style}Kernel:{unstyle} {}", kernel().unwrap(), style = style, unstyle = unstyle); 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 uptime = format!("{style}Uptime:{unstyle} {}", &uptime().unwrap()[3..], style = style, unstyle = unstyle);
let info = [ let mut info = vec![
String::from("\n"), String::from("\n"),
username, username,
osname, osname,
@ -28,6 +28,15 @@ pub fn main() {
uptime, uptime,
]; ];
for arg in args().skip(1) {
let split = arg.split(":").collect::<Vec<_>>();
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 logo_iterator = Os::ArchLinux.ascii_logo().lines();
let mut info_iterator = info.iter(); let mut info_iterator = info.iter();