Receive user input (password)

This commit is contained in:
Adam Cooper 2021-12-13 14:23:25 -05:00
parent f020ecb6d9
commit 585b247297

View file

@ -1,16 +1,22 @@
extern crate xml;
#[allow(unused)]
// use dotenv::dotenv;
use env_logger::{ Env, Target };
#[allow(unused)]
use log::{debug, info, log_enabled, warn, error};
use reqwest;
#[allow(unused)]
use std::io::{self, Write};
#[allow(unused)]
use xml::reader::{EventReader, XmlEvent};
#[allow(unused)]
fn publicise() {
}
#[allow(unused)]
async fn traverse(password: &str) -> Result<reqwest::Response, Box<dyn std::error::Error>> {
let root_url = "https://theadamcooper.com";
let url_tail = "/nextcloud/remote.php/dav/files/adam/public";
@ -20,19 +26,24 @@ async fn traverse(password: &str) -> Result<reqwest::Response, Box<dyn std::erro
.basic_auth("adam", Some(password))
.send()
.await?;
// env_logger::Debug(response);
debug!("{:?}", response);
Ok(response)
}
fn main() {
env_logger::Builder::from_env(Env::default().default_filter_or("trace")).target(Target::Stdout).init();
println!("Publicise it!");
fn get_password() -> Result<String, std::io::Error> {
print!("Nextcloud password: ");
io::stdout().flush().unwrap();
let mut buffer = String::new();
let stdin = io::stdin();
match stdin.read_line(&mut buffer) {
Ok(_) => debug!("buffer: {}", buffer),
Err(error) => println!("error: {}", error),
};
Ok(_) => Ok(buffer),
Err(error) => Err(error),
}
}
fn main() {
env_logger::Builder::from_env(Env::default().default_filter_or("trace")).target(Target::Stdout).init();
println!("Publicise it!");
let password = get_password().unwrap();
debug!("Received password: {}", password);
}