swaybar_info/src/args.rs

27 lines
866 B
Rust
Raw Normal View History

2022-07-09 08:33:19 +00:00
use std::collections::HashMap;
pub fn get_args() -> HashMap<String, String> {
let mut map = HashMap::new();
for arg in std::env::args() {
if arg.starts_with("--netdev=") {
let (_, back) = arg.split_at(9);
map.insert("netdev".into(), back.into());
2022-07-09 09:18:12 +00:00
} else if arg.starts_with("--interval-sec=") {
let (_, back) = arg.split_at(15);
map.insert("interval-sec".into(), back.into());
} else if arg.starts_with("--help") || arg.starts_with("-h") {
map.insert("help".into(), "".into());
2022-07-09 08:33:19 +00:00
}
}
map
}
2022-07-09 09:18:12 +00:00
pub fn print_usage() {
println!("Usage:");
println!(" --help\t\t\tPrints help");
println!(" --netdev=<device_name>\tCheck network traffic on specified device");
2022-07-09 10:00:39 +00:00
println!(" --interval-sec=<seconds>\tOutput at intervals of <seconds> (default 5)");
2022-07-09 09:18:12 +00:00
}