Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
cli: Add `rad self --address` command
Merged did:key:z6MksFqX...wzpT opened 2 years ago

Useful when running seed nodes.

3 files changed +22 -2 131103cb c13c658f
modified radicle-cli/examples/rad-self.md
@@ -38,3 +38,8 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1
$ rad self --home
[..]/home/alice/.radicle
```
+

+
```
+
$ rad self --address
+
z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi@seed.alice.acme:8776
+
```
modified radicle-cli/src/commands/self.rs
@@ -1,6 +1,7 @@
use std::ffi::OsString;

use radicle::crypto::ssh;
+
use radicle::node::config::ConnectAddress;
use radicle::Profile;

use crate::terminal as term;
@@ -18,9 +19,10 @@ Usage

Options

+
    --did                Show your DID
    --alias              Show your Node alias
    --nid                Show your Node ID (NID)
-
    --did                Show your DID
+
    --address            Show your Node address(es)
    --home               Show your Radicle home
    --config             Show the location of your configuration file
    --ssh-key            Show your public key in OpenSSH format
@@ -32,6 +34,7 @@ Options
#[derive(Debug)]
enum Show {
    Alias,
+
    Address,
    NodeId,
    Did,
    Home,
@@ -58,6 +61,9 @@ impl Args for Options {
                Long("alias") if show.is_none() => {
                    show = Some(Show::Alias);
                }
+
                Long("address") if show.is_none() => {
+
                    show = Some(Show::Address);
+
                }
                Long("nid") if show.is_none() => {
                    show = Some(Show::NodeId);
                }
@@ -99,6 +105,12 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
        Show::Alias => {
            term::print(profile.config.alias());
        }
+
        Show::Address => {
+
            let nid = profile.public_key;
+
            for addr in profile.config.node.external_addresses {
+
                term::print(ConnectAddress::from((nid, addr)).to_string());
+
            }
+
        }
        Show::NodeId => {
            term::print(profile.id());
        }
modified radicle-cli/tests/commands.rs
@@ -1161,7 +1161,10 @@ fn rad_sync_without_node() {
#[test]
fn rad_self() {
    let mut environment = Environment::new();
-
    let alice = environment.node(Config::test(Alias::new("alice")));
+
    let alice = environment.node(Config {
+
        external_addresses: vec!["seed.alice.acme:8776".parse().unwrap()],
+
        ..Config::test(Alias::new("alice"))
+
    });
    let working = environment.tmp().join("working");

    test("examples/rad-self.md", working, Some(&alice.home), []).unwrap();