Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Be less confusing when asking for passphrase
Alexis Sellier committed 2 years ago
commit 5040f33025d6ba7a68dca5f9e1eb8053888b623b
parent 30f2e2260a93cd2249320986a68c94862099da53
3 files changed +8 -9
modified radicle-cli/src/commands/auth.rs
@@ -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"));
modified radicle-cli/src/commands/node/control.rs
@@ -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
modified radicle-term/src/io.rs
@@ -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 {