mirror of
https://github.com/FliegendeWurst/KIT-ILIAS-downloader.git
synced 2024-08-28 04:04:18 +00:00
Compare commits
No commits in common. "38ce269d7052bd6f62732d6af5d86ce353940cb7" and "f21c0249ed971cda710d07be8af35e819eda7df9" have entirely different histories.
38ce269d70
...
f21c0249ed
35
src/cli.rs
35
src/cli.rs
@ -1,8 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
use std::io::{Error, ErrorKind};
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
|
||||||
use std::sync::atomic::{AtomicBool, AtomicUsize};
|
use std::sync::atomic::{AtomicBool, AtomicUsize};
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
@ -74,10 +72,6 @@ pub struct Opt {
|
|||||||
#[structopt(short = "P", long)]
|
#[structopt(short = "P", long)]
|
||||||
pub password: Option<String>,
|
pub password: Option<String>,
|
||||||
|
|
||||||
/// Path inside `pass(1)` to the password for shibboleth.
|
|
||||||
#[structopt(long)]
|
|
||||||
pub pass_path: Option<String>,
|
|
||||||
|
|
||||||
/// ILIAS page to download
|
/// ILIAS page to download
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
pub sync_url: Option<String>,
|
pub sync_url: Option<String>,
|
||||||
@ -176,35 +170,6 @@ pub fn ask_user_pass(opt: &Opt) -> Result<(String, String)> {
|
|||||||
should_store = true;
|
should_store = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let Some(pass_path) = &opt.pass_path {
|
|
||||||
let pw_out = Command::new("pass")
|
|
||||||
.arg("show")
|
|
||||||
.arg(pass_path)
|
|
||||||
.output()
|
|
||||||
.map_err(|x| {
|
|
||||||
if x.kind() == ErrorKind::NotFound {
|
|
||||||
Error::new(ErrorKind::NotFound, "pass not found in $PATH!")
|
|
||||||
} else {
|
|
||||||
x
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
if !pw_out.status.success() {
|
|
||||||
return Err(Error::new(
|
|
||||||
ErrorKind::Other,
|
|
||||||
format!(
|
|
||||||
"`pass` failed with non-zero exit code {}: {}",
|
|
||||||
pw_out.status.code()
|
|
||||||
.expect("Failed retrieving pass exit code!"),
|
|
||||||
String::from_utf8(pw_out.stderr)
|
|
||||||
.expect("Failed decoding stderr of pass!")
|
|
||||||
)
|
|
||||||
))?
|
|
||||||
} else {
|
|
||||||
pass = String::from_utf8(pw_out.stdout).map(|x| {
|
|
||||||
x.trim_end().to_string()
|
|
||||||
}).expect("utf-8 decode of `pass(1)`-output failed");
|
|
||||||
should_store = false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
pass = rpassword::prompt_password("Password: ").context("password prompt")?;
|
pass = rpassword::prompt_password("Password: ").context("password prompt")?;
|
||||||
should_store = true;
|
should_store = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user