Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: Move args to its own module
Erik Kundt committed 6 months ago
commit 455ddd9cbdebc72eab7d532fcd31faf33146f0b2
parent f84ae4af692629905d34df1d247cdd03f5930a07
2 files changed +25 -20
modified crates/radicle-cli/src/commands/auth.rs
@@ -1,10 +1,10 @@
#![allow(clippy::or_fun_call)]
+
mod args;
+

use std::str::FromStr;

use anyhow::{anyhow, Context};

-
use clap::Parser;
-

use radicle::crypto::ssh;
use radicle::crypto::ssh::Passphrase;
use radicle::node::Alias;
@@ -13,24 +13,8 @@ use radicle::{profile, Profile};

use crate::terminal as term;

-
pub(crate) const ABOUT: &str = "Manage identities and profiles";
-
const LONG_ABOUT: &str = r#"
-
A passphrase may be given via the environment variable `RAD_PASSPHRASE` or
-
via the standard input stream if `--stdin` is used. Using either of these
-
methods disables the passphrase prompt.
-
"#;
-

-
#[derive(Debug, Parser)]
-
#[command(about = ABOUT, long_about = LONG_ABOUT, disable_version_flag = true)]
-
pub struct Args {
-
    /// When initializing an identity, sets the node alias
-
    #[arg(long, value_name = "STRING")]
-
    pub alias: Option<Alias>,
-

-
    /// Read passphrase from stdin (default: false)
-
    #[arg(long)]
-
    pub stdin: bool,
-
}
+
pub use args::Args;
+
pub(crate) use args::ABOUT;

pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
    match ctx.profile() {
added crates/radicle-cli/src/commands/auth/args.rs
@@ -0,0 +1,21 @@
+
use clap::Parser;
+
use radicle::node::Alias;
+

+
pub(crate) const ABOUT: &str = "Manage identities and profiles";
+
const LONG_ABOUT: &str = r#"
+
A passphrase may be given via the environment variable `RAD_PASSPHRASE` or
+
via the standard input stream if `--stdin` is used. Using either of these
+
methods disables the passphrase prompt.
+
"#;
+

+
#[derive(Debug, Parser)]
+
#[command(about = ABOUT, long_about = LONG_ABOUT, disable_version_flag = true)]
+
pub struct Args {
+
    /// When initializing an identity, sets the node alias
+
    #[arg(long, value_name = "STRING")]
+
    pub alias: Option<Alias>,
+

+
    /// Read passphrase from stdin (default: false)
+
    #[arg(long)]
+
    pub stdin: bool,
+
}