aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-09-07 15:11:02 -0400
committerBen Morrison <ben@gbmor.dev>2019-09-07 15:11:02 -0400
commit55a574b788cdd6fb67f637242fc5476e14d73092 (patch)
treea1be6a57c68ec8b7481e44518f7a121f644abba4 /src
parent674b999a4e1979f7452ead7bd3856fa5ec949d77 (diff)
downloadinstistats-55a574b788cdd6fb67f637242fc5476e14d73092.tar.gz
walking home directory for user list
Diffstat (limited to 'src')
-rw-r--r--src/main.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 103cbc6..066454d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,9 +1,11 @@
use std::env;
use std::fs;
+use std::path::Path;
use std::process;
use serde::{Deserialize, Serialize};
use serde_yaml;
+use walkdir::WalkDir;
const VERS: &str = "v0.1";
const CONF_PATH: &str = "instistats.yml";
@@ -48,5 +50,29 @@ fn main() {
let conf_yaml: Server =
serde_yaml::from_str(&conf).expect("Could not parse config data as YAML");
- println!("{:#?}", conf_yaml);
+ eprintln!("{:#?}", conf_yaml);
+
+ let home_dir = WalkDir::new("/home").follow_links(true).max_depth(1);
+ let mut users_list = Vec::new();
+ home_dir.into_iter().for_each(|d| {
+ if let Ok(p) = d {
+ let p = p.path().strip_prefix("/home").unwrap();
+ let p = p.to_str().unwrap();
+ if p.len() > 1 {
+ let user = p
+ .chars()
+ .map(|c| {
+ if c != '"' {
+ c.to_string()
+ } else {
+ "".to_string()
+ }
+ })
+ .collect::<String>();
+ users_list.push(user);
+ }
+ }
+ });
+
+ eprintln!("{:?}", users_list);
}