init
This commit is contained in:
commit
c5731665a3
25 changed files with 1110 additions and 0 deletions
39
yunohost-api/examples/info.rs
Normal file
39
yunohost-api/examples/info.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use yunohost_api::{YunohostUsers, Username};
|
||||
|
||||
use std::io::{BufRead, Stdin, stdin};
|
||||
use std::str::FromStr;
|
||||
|
||||
fn acquire_loop<T: FromStr>(input: &Stdin, message: &str) -> T
|
||||
where <T as FromStr>::Err: std::fmt::Display {
|
||||
loop {
|
||||
println!("{message}");
|
||||
let value = input.lock().lines().next().unwrap().unwrap();
|
||||
match T::from_str(&value) {
|
||||
Ok(v) => {
|
||||
return v;
|
||||
}, Err(e) => {
|
||||
println!("{}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let input = stdin();
|
||||
let users = YunohostUsers::new(500).await.unwrap();
|
||||
|
||||
loop {
|
||||
println!("Welcome to Yunohost! What user would you like to know about?");
|
||||
|
||||
let username: Username = acquire_loop(&input, "Username:");
|
||||
|
||||
if users.get_user(&username).await.unwrap() {
|
||||
println!("User found!");
|
||||
} else {
|
||||
println!("User not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue