Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/node: Print Node ID
Lorenz Leutgeb committed 8 months ago
commit e1af550a0907304c2c520d6a49fc8c6185996948
parent 9b7529baa7287c2331d0424d79579df92d145f57
2 files changed +31 -18
modified crates/radicle-cli/examples/rad-node.md
@@ -15,7 +15,7 @@ node status` command (or just `rad node` for short):

```
$ rad node status
-
✓ Node is running and listening on [..].
+
✓ Node is running with Node ID z6MknSL[..]Vi and listening for inbound connections on [..].
```

```
modified crates/radicle-cli/src/commands/node/control.rs
@@ -263,23 +263,7 @@ pub fn status(node: &Node, profile: &Profile) -> anyhow::Result<()> {
        term::warning(warning);
    }

-
    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 {
+
    if !node.is_running() {
        term::info!("Node is {}.", term::format::negative("stopped"));
        term::info!(
            "To start it, run {}.",
@@ -288,6 +272,35 @@ pub fn status(node: &Node, profile: &Profile) -> anyhow::Result<()> {
        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)?;
    if let Some(table) = sessions {
        term::blank();