From 001e890f9b093e32fae4a4cee7942dded2fec92c Mon Sep 17 00:00:00 2001 From: obito1903 Date: Fri, 29 Apr 2022 15:35:59 +0200 Subject: [PATCH] Password can now be passed as argument --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 2d5a06e..c20e308 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,8 @@ struct Opt { tracks: Vec, #[structopt(short = "u", long = "username", help = "Your Spotify username")] username: String, + #[structopt(short = "p", long = "password", help = "Your Spotify password")] + password: Option, #[structopt(short = "d", long = "destination", default_value = ".", help = "The directory where the songs will be downloaded")] destination: String } @@ -85,7 +87,7 @@ fn main() { let mut core = Core::new().unwrap(); let username = opt.username; - let password = rpassword::read_password_from_tty(Some("Password: ")).unwrap(); + let password = opt.password.unwrap_or_else(|| rpassword::read_password_from_tty(Some("Password: ")).unwrap()); let credentials = Credentials::with_password(username, password); let session = create_session(&mut core, credentials.clone());