Implement logging and user input

This commit is contained in:
Adam Cooper 2021-12-13 01:20:45 -05:00
parent f6de295e4c
commit f020ecb6d9
4 changed files with 1156 additions and 2 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
/target
.env
Cargo.lock

1111
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -6,3 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dotenv = "0.15.0"
env_logger = "0.8.4"
log = "0.4.0"
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }
xml-rs = "0.8.4"

View file

@ -1,3 +1,38 @@
fn main() {
println!("Hello, world!");
extern crate xml;
// use dotenv::dotenv;
use env_logger::{ Env, Target };
use log::{debug, info, log_enabled, warn, error};
use reqwest;
use std::io::{self, Write};
use xml::reader::{EventReader, XmlEvent};
fn publicise() {
}
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";
let method = reqwest::Method::from_bytes(b"PROPFIND").unwrap();
let client = reqwest::Client::new();
let response = client.request(method, root_url)
.basic_auth("adam", Some(password))
.send()
.await?;
// env_logger::Debug(response);
Ok(response)
}
fn main() {
env_logger::Builder::from_env(Env::default().default_filter_or("trace")).target(Target::Stdout).init();
println!("Publicise it!");
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),
};
}