mirror of
https://github.com/FliegendeWurst/KIT-ILIAS-downloader.git
synced 2024-08-28 04:04:18 +00:00
Make keyring support non-optional
Now that the dbus library isn't needed..
This commit is contained in:
parent
bd9a777bb9
commit
126f8500e4
772
Cargo.lock
generated
772
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "KIT-ILIAS-downloader"
|
name = "KIT-ILIAS-downloader"
|
||||||
version = "0.2.24"
|
version = "0.3.0"
|
||||||
authors = ["FliegendeWurst <2012gdwu@posteo.de>"]
|
authors = ["FliegendeWurst <2012gdwu@posteo.de>"]
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@ -24,18 +24,14 @@ rprompt = "1.0.5"
|
|||||||
ignore = "0.4.14"
|
ignore = "0.4.14"
|
||||||
anyhow = "1.0.28"
|
anyhow = "1.0.28"
|
||||||
colored = "2.0.0"
|
colored = "2.0.0"
|
||||||
keyring = { version = "0.10.1", optional = true }
|
keyring = "1.0.0"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
indicatif = "0.16.0"
|
indicatif = "0.16.0"
|
||||||
once_cell = "1.7.2"
|
once_cell = "1.7.2"
|
||||||
atty = "0.2.14"
|
atty = "0.2.14"
|
||||||
h2 = "0.3.3"
|
h2 = "0.3.3"
|
||||||
cookie_store = "0.14.0"
|
cookie_store = "0.15.1"
|
||||||
reqwest_cookie_store = "0.1.5"
|
reqwest_cookie_store = "0.2.0"
|
||||||
bytes = "1.0.1"
|
bytes = "1.0.1"
|
||||||
toml = "0.5.8"
|
toml = "0.5.8"
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
keyring-auth = ["keyring"]
|
|
||||||
|
19
src/cli.rs
19
src/cli.rs
@ -3,7 +3,6 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize};
|
use std::sync::atomic::{AtomicBool, AtomicUsize};
|
||||||
|
|
||||||
#[cfg(feature = "keyring-auth")]
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use indicatif::ProgressBar;
|
use indicatif::ProgressBar;
|
||||||
@ -63,7 +62,6 @@ pub struct Opt {
|
|||||||
|
|
||||||
/// Use the system keyring
|
/// Use the system keyring
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
#[cfg(feature = "keyring-auth")]
|
|
||||||
pub keyring: bool,
|
pub keyring: bool,
|
||||||
|
|
||||||
/// KIT account username
|
/// KIT account username
|
||||||
@ -151,14 +149,8 @@ pub fn ask_user_pass(opt: &Opt) -> Result<(String, String)> {
|
|||||||
} else {
|
} else {
|
||||||
rprompt::prompt_reply_stdout("Username: ").context("username prompt")?
|
rprompt::prompt_reply_stdout("Username: ").context("username prompt")?
|
||||||
};
|
};
|
||||||
#[cfg(feature = "keyring-auth")]
|
|
||||||
let (pass, should_store);
|
let (pass, should_store);
|
||||||
#[cfg(feature = "keyring-auth")]
|
let keyring = Lazy::new(|| keyring::Entry::new(env!("CARGO_PKG_NAME"), &user));
|
||||||
let keyring = Lazy::new(|| keyring::Keyring::new(env!("CARGO_PKG_NAME"), &user));
|
|
||||||
#[cfg(not(feature = "keyring-auth"))]
|
|
||||||
let pass;
|
|
||||||
cfg_if::cfg_if! { // TODO: deduplicate the logic below
|
|
||||||
if #[cfg(feature = "keyring-auth")] {
|
|
||||||
if let Some(password) = opt.password.as_ref() {
|
if let Some(password) = opt.password.as_ref() {
|
||||||
pass = password.clone();
|
pass = password.clone();
|
||||||
should_store = true;
|
should_store = true;
|
||||||
@ -178,15 +170,6 @@ pub fn ask_user_pass(opt: &Opt) -> Result<(String, String)> {
|
|||||||
pass = rpassword::read_password_from_tty(Some("Password: ")).context("password prompt")?;
|
pass = rpassword::read_password_from_tty(Some("Password: ")).context("password prompt")?;
|
||||||
should_store = true;
|
should_store = true;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if let Some(password) = opt.password.as_ref() {
|
|
||||||
pass = password.clone();
|
|
||||||
} else {
|
|
||||||
pass = rpassword::read_password_from_tty(Some("Password: ")).context("password prompt")?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#[cfg(feature = "keyring-auth")]
|
|
||||||
if should_store && opt.keyring {
|
if should_store && opt.keyring {
|
||||||
keyring.set_password(&pass).map_err(|x| anyhow!(x.to_string()))?;
|
keyring.set_password(&pass).map_err(|x| anyhow!(x.to_string()))?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user