use flickr_api::*;
use std::env;
use std::error::Error;
use std::io::{self, Write};
use std::path::Path;
fn prompt(message: &str) -> String {
let mut input = String::new();
print!("{message}");
io::stdout().flush().ok();
io::stdin()
.read_line(&mut input)
.expect("Failed to read line");
input.trim().to_string()
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let arg = env::args().nth(1).unwrap();
let path = Path::new(&arg);
println!("Uploading {path:?}");
let client = FlickrAPI::new(ApiKey {
key: prompt("API key: "),
secret: prompt("API secret: "),
})
.login()
.await?;
let id = client.photos().upload_from_path(&path).await?;
println!("Uploaded {path:?} and was given {id}");
Ok(())
}