cli/node: Print Node ID
If we ever want to disentangle the users' identity from the node, then the `rad node` commands must learn to print the information related to the node, so here we go.
This commit is contained in:
parent
9b7529baa7
commit
e1af550a09
|
|
@ -15,7 +15,7 @@ node status` command (or just `rad node` for short):
|
||||||
|
|
||||||
```
|
```
|
||||||
$ rad node status
|
$ rad node status
|
||||||
✓ Node is running and listening on [..].
|
✓ Node is running with Node ID z6MknSL[..]Vi and listening for inbound connections on [..].
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -263,23 +263,7 @@ pub fn status(node: &Node, profile: &Profile) -> anyhow::Result<()> {
|
||||||
term::warning(warning);
|
term::warning(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.is_running() {
|
if !node.is_running() {
|
||||||
let listen = node
|
|
||||||
.listen_addrs()?
|
|
||||||
.into_iter()
|
|
||||||
.map(|addr| addr.to_string())
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
if listen.is_empty() {
|
|
||||||
term::success!("Node is {}.", term::format::positive("running"));
|
|
||||||
} else {
|
|
||||||
term::success!(
|
|
||||||
"Node is {} and listening on {}.",
|
|
||||||
term::format::positive("running"),
|
|
||||||
listen.join(", ")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
term::info!("Node is {}.", term::format::negative("stopped"));
|
term::info!("Node is {}.", term::format::negative("stopped"));
|
||||||
term::info!(
|
term::info!(
|
||||||
"To start it, run {}.",
|
"To start it, run {}.",
|
||||||
|
|
@ -288,6 +272,35 @@ pub fn status(node: &Node, profile: &Profile) -> anyhow::Result<()> {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let listen = node
|
||||||
|
.listen_addrs()?
|
||||||
|
.into_iter()
|
||||||
|
.map(|addr| addr.to_string())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let nid = node.nid()?;
|
||||||
|
let nid = if &nid == profile.id() {
|
||||||
|
term::format::tertiary(term::format::node_id_human(&nid))
|
||||||
|
} else {
|
||||||
|
term::format::yellow(term::format::node_id_human(&nid)).bold()
|
||||||
|
};
|
||||||
|
|
||||||
|
if listen.is_empty() {
|
||||||
|
term::success!(
|
||||||
|
"Node is {} with Node ID {} and {} configured to listen for inbound connections.",
|
||||||
|
term::format::positive("running"),
|
||||||
|
nid,
|
||||||
|
term::Paint::new("not").italic()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
term::success!(
|
||||||
|
"Node is {} with Node ID {} and listening for inbound connections on {}.",
|
||||||
|
term::format::positive("running"),
|
||||||
|
nid,
|
||||||
|
listen.join(", ")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let sessions = sessions(node)?;
|
let sessions = sessions(node)?;
|
||||||
if let Some(table) = sessions {
|
if let Some(table) = sessions {
|
||||||
term::blank();
|
term::blank();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue