1use flickr_api::*;
2use std::env;
3use std::error::Error;
4use std::io::{self, Write};
5use std::path::Path;
6
7fn prompt(message: &str) -> String {
8 let mut input = String::new();
10
11 print!("{message}");
13
14 io::stdout().flush().ok();
16
17 io::stdin()
19 .read_line(&mut input)
20 .expect("Failed to read line");
21
22 input.trim().to_string()
24}
25
26#[tokio::main]
27async fn main() -> Result<(), Box<dyn Error>> {
28 let arg = env::args().nth(1).unwrap();
29 let path = Path::new(&arg);
30 println!("Uploading {path:?}");
31
32 let client = FlickrAPI::new(ApiKey {
33 key: prompt("API key: "),
34 secret: prompt("API secret: "),
35 })
36 .login()
37 .await?;
38
39 let id = client.photos().upload_from_path(&path).await?;
40 println!("Uploaded {path:?} and was given {id}");
41
42 Ok(())
43}