cli: Be less confusing when asking for passphrase
The previous error didn't really make sense.
This commit is contained in:
parent
30f2e2260a
commit
5040f33025
|
|
@ -178,10 +178,10 @@ pub fn authenticate(options: Options, profile: &Profile) -> anyhow::Result<()> {
|
|||
);
|
||||
|
||||
let passphrase = if options.stdin {
|
||||
term::passphrase_stdin()
|
||||
term::passphrase_stdin()?
|
||||
} else {
|
||||
term::passphrase(RAD_PASSPHRASE)
|
||||
}?;
|
||||
term::passphrase(RAD_PASSPHRASE)?
|
||||
};
|
||||
register(&mut agent, profile, passphrase)?;
|
||||
|
||||
term::success!("Radicle key added to {}", term::format::dim("ssh-agent"));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use std::fs::{File, OpenOptions};
|
|||
use std::io::{BufRead, BufReader, Read, Seek, SeekFrom};
|
||||
use std::{process, thread, time};
|
||||
|
||||
use anyhow::Context as _;
|
||||
use localtime::LocalTime;
|
||||
|
||||
use radicle::node;
|
||||
|
|
@ -30,10 +29,10 @@ pub fn start(
|
|||
}
|
||||
let envs = if profile.keystore.is_encrypted()? {
|
||||
// Ask passphrase here, otherwise it'll be a fatal error when running the daemon
|
||||
// without `RAD_PASSPHRASE`. To keep things consistent, we also use this in foreground mode.
|
||||
let passphrase = term::io::passphrase(profile::env::RAD_PASSPHRASE)
|
||||
.context(format!("`{}` must be set", profile::env::RAD_PASSPHRASE))?;
|
||||
|
||||
// without `RAD_PASSPHRASE`.
|
||||
let Ok(passphrase) = term::io::passphrase(profile::env::RAD_PASSPHRASE) else {
|
||||
anyhow::bail!("your radicle passphrase is required to start your node");
|
||||
};
|
||||
Some((profile::env::RAD_PASSPHRASE, passphrase))
|
||||
} else {
|
||||
None
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ where
|
|||
Ok(value)
|
||||
}
|
||||
|
||||
pub fn passphrase<K: AsRef<OsStr>>(var: K) -> Result<Passphrase, anyhow::Error> {
|
||||
pub fn passphrase<K: AsRef<OsStr>>(var: K) -> Result<Passphrase, inquire::InquireError> {
|
||||
if let Ok(p) = env::var(var) {
|
||||
Ok(Passphrase::from(p))
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue