cli: Move node addresses command
To make things a little more consistent, move the `rad self --address` command to `rad node config --addresses`, since it's more about externally-facing configuration of the node, rather than your local user or profile.
This commit is contained in:
parent
091f7b7e98
commit
a48081f271
|
|
@ -18,6 +18,12 @@ $ rad node status
|
|||
✓ Node is running and listening on [..].
|
||||
```
|
||||
|
||||
```
|
||||
$ rad node config --addresses
|
||||
z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi@41.12.98.112:8776
|
||||
z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi@seed.cloudhead.io:8776
|
||||
```
|
||||
|
||||
The node also allows us to query data that it has access to such as
|
||||
the follow policies and the routing table. Before we explore
|
||||
those commands we'll first follow a peer so that we have something to
|
||||
|
|
|
|||
|
|
@ -38,8 +38,3 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1
|
|||
$ rad self --home
|
||||
[..]/home/alice/.radicle
|
||||
```
|
||||
|
||||
```
|
||||
$ rad self --address
|
||||
z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi@seed.alice.acme:8776
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ use std::time;
|
|||
|
||||
use anyhow::anyhow;
|
||||
|
||||
use radicle::node::config::ConnectAddress;
|
||||
use radicle::node::Handle as _;
|
||||
use radicle::node::{Address, Node, NodeId, PeerAddr};
|
||||
use radicle::prelude::RepoId;
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ Usage
|
|||
rad node connect <nid>@<addr> [<option>...]
|
||||
rad node routing [--rid <rid>] [--nid <nid>] [--json] [<option>...]
|
||||
rad node events [--timeout <secs>] [-n <count>] [<option>...]
|
||||
rad node config
|
||||
rad node config [--addresses]
|
||||
|
||||
For `<node-option>` see `radicle-node --help`.
|
||||
|
||||
|
|
@ -68,7 +70,9 @@ pub enum Operation {
|
|||
addr: PeerAddr<NodeId, Address>,
|
||||
timeout: time::Duration,
|
||||
},
|
||||
Config,
|
||||
Config {
|
||||
addresses: bool,
|
||||
},
|
||||
Events {
|
||||
timeout: time::Duration,
|
||||
count: usize,
|
||||
|
|
@ -121,6 +125,7 @@ impl Args for Options {
|
|||
let mut lines: usize = 60;
|
||||
let mut count: usize = usize::MAX;
|
||||
let mut timeout = time::Duration::MAX;
|
||||
let mut addresses = false;
|
||||
let mut path = None;
|
||||
let mut verbose = false;
|
||||
|
||||
|
|
@ -167,6 +172,9 @@ impl Args for Options {
|
|||
Long("foreground") if matches!(op, Some(OperationName::Start)) => {
|
||||
foreground = true;
|
||||
}
|
||||
Long("addresses") if matches!(op, Some(OperationName::Config)) => {
|
||||
addresses = true;
|
||||
}
|
||||
Long("verbose") | Short('v') if matches!(op, Some(OperationName::Start)) => {
|
||||
verbose = true;
|
||||
}
|
||||
|
|
@ -191,7 +199,7 @@ impl Args for Options {
|
|||
})?,
|
||||
timeout,
|
||||
},
|
||||
OperationName::Config => Operation::Config,
|
||||
OperationName::Config => Operation::Config { addresses },
|
||||
OperationName::Events => Operation::Events { timeout, count },
|
||||
OperationName::Routing => Operation::Routing { rid, nid, json },
|
||||
OperationName::Logs => Operation::Logs { lines },
|
||||
|
|
@ -217,7 +225,16 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
Operation::Connect { addr, timeout } => {
|
||||
control::connect(&mut node, addr.id, addr.addr, timeout)?
|
||||
}
|
||||
Operation::Config => control::config(&node)?,
|
||||
Operation::Config { addresses } => {
|
||||
if addresses {
|
||||
let cfg = node.config()?;
|
||||
for addr in cfg.external_addresses {
|
||||
term::print(ConnectAddress::from((*profile.id(), addr)).to_string());
|
||||
}
|
||||
} else {
|
||||
control::config(&node)?;
|
||||
}
|
||||
}
|
||||
Operation::Sessions => {
|
||||
let sessions = control::sessions(&node)?;
|
||||
if let Some(table) = sessions {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use std::ffi::OsString;
|
||||
|
||||
use radicle::crypto::ssh;
|
||||
use radicle::node::config::ConnectAddress;
|
||||
use radicle::Profile;
|
||||
|
||||
use crate::terminal as term;
|
||||
|
|
@ -22,7 +21,6 @@ Options
|
|||
--did Show your DID
|
||||
--alias Show your Node alias
|
||||
--nid Show your Node ID (NID)
|
||||
--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
|
||||
|
|
@ -34,7 +32,6 @@ Options
|
|||
#[derive(Debug)]
|
||||
enum Show {
|
||||
Alias,
|
||||
Address,
|
||||
NodeId,
|
||||
Did,
|
||||
Home,
|
||||
|
|
@ -61,9 +58,6 @@ 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);
|
||||
}
|
||||
|
|
@ -105,12 +99,6 @@ 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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use std::{env, thread, time};
|
||||
use std::{env, net, thread, time};
|
||||
|
||||
use radicle::git;
|
||||
use radicle::node;
|
||||
|
|
@ -8,7 +8,7 @@ use radicle::node::address::Store as _;
|
|||
use radicle::node::config::seeds::{RADICLE_COMMUNITY_NODE, RADICLE_TEAM_NODE};
|
||||
use radicle::node::routing::Store as _;
|
||||
use radicle::node::Handle as _;
|
||||
use radicle::node::{Alias, DEFAULT_TIMEOUT};
|
||||
use radicle::node::{Address, Alias, DEFAULT_TIMEOUT};
|
||||
use radicle::prelude::RepoId;
|
||||
use radicle::profile;
|
||||
use radicle::profile::Home;
|
||||
|
|
@ -582,7 +582,13 @@ fn rad_node_connect() {
|
|||
#[test]
|
||||
fn rad_node() {
|
||||
let mut environment = Environment::new();
|
||||
let alice = environment.node(Config::test(Alias::new("alice")));
|
||||
let alice = environment.node(Config {
|
||||
external_addresses: vec![
|
||||
Address::from(net::SocketAddr::from(([41, 12, 98, 112], 8776))),
|
||||
Address::from_str("seed.cloudhead.io:8776").unwrap(),
|
||||
],
|
||||
..Config::test(Alias::new("alice"))
|
||||
});
|
||||
let working = tempfile::tempdir().unwrap();
|
||||
let alice = alice.spawn();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue