diff --git a/radicle-cli/examples/rad-self.md b/radicle-cli/examples/rad-self.md index a486efc8..6acf3ba9 100644 --- a/radicle-cli/examples/rad-self.md +++ b/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 +``` diff --git a/radicle-cli/src/commands/self.rs b/radicle-cli/src/commands/self.rs index f4493e75..94c3b2a3 100644 --- a/radicle-cli/src/commands/self.rs +++ b/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()); } diff --git a/radicle-cli/tests/commands.rs b/radicle-cli/tests/commands.rs index 2d62ddcd..3c2b29fd 100644 --- a/radicle-cli/tests/commands.rs +++ b/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();