From f00d1d67432882bef11fc940601f071efe55c88d Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Wed, 27 Aug 2025 00:09:37 +0200 Subject: [PATCH] cli/self: Stop printing information about the node To get to a point of separating the users' identity from the node, then the `rad self` command should not display information related to the node so prominently. The relation between `rad` and `radicle-node` is really similar to that between `rad` and SSH Agent. They communicate via socket. So, when this connection is successful, it is printed, but not more. There may be some re-learning for users here, but it is worth the improvement. Note that the information being removed here is available via `rad node status` (see previous commit). --- build/upload | 2 +- crates/radicle-cli/examples/rad-self.md | 23 +++++++++-------- crates/radicle-cli/src/commands/self.rs | 31 +++++++++++++++------- crates/radicle-cli/src/commands/watch.rs | 2 +- rad.1.adoc | 2 +- scripts/delete-remote-refs.sh | 33 ------------------------ 6 files changed, 36 insertions(+), 57 deletions(-) delete mode 100755 scripts/delete-remote-refs.sh diff --git a/build/upload b/build/upload index 43543b9c..acfeff6d 100755 --- a/build/upload +++ b/build/upload @@ -7,7 +7,7 @@ SSH_KEY="$(rad path)/keys/radicle" main() { version="$(build/version)" - nid="$(rad self --nid)" + nid="$(rad self --did | cut -d: -f3-)" rad_url="$(rad . | sed s/rad:/rad:\\/\\//)" rad_remote="$rad_url/$nid" diff --git a/crates/radicle-cli/examples/rad-self.md b/crates/radicle-cli/examples/rad-self.md index a486efc8..25cd57e3 100644 --- a/crates/radicle-cli/examples/rad-self.md +++ b/crates/radicle-cli/examples/rad-self.md @@ -3,17 +3,17 @@ device and node. ``` $ rad self -Alias alice -DID did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi -└╴Node ID (NID) z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi -SSH not running -├╴Key (hash) SHA256:UIedaL6Cxm6OUErh9GQUzzglSk7VpQlVTI1TAFB/HWA -└╴Key (full) ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1 -Home [..]/home/alice/.radicle -├╴Config [..]/home/alice/.radicle/config.json -├╴Storage [..]/home/alice/.radicle/storage -├╴Keys [..]/home/alice/.radicle/keys -└╴Node [..]/home/alice/.radicle/node +Alias alice +DID did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi +Node not running +SSH not running +├╴Key (hash) SHA256:UIedaL6Cxm6OUErh9GQUzzglSk7VpQlVTI1TAFB/HWA +└╴Key (full) ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1 +Home [..]/home/alice/.radicle +├╴Config [..]/home/alice/.radicle/config.json +├╴Storage [..]/home/alice/.radicle/storage +├╴Keys [..]/home/alice/.radicle/keys +└╴Node [..]/home/alice/.radicle/node ``` If you need to display only your DID, Node ID, or SSH Public Key, you can use @@ -26,6 +26,7 @@ did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi ``` $ rad self --nid +! Warning: The option `--nid` is deprecated, please use `rad node status` instead. z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi ``` diff --git a/crates/radicle-cli/src/commands/self.rs b/crates/radicle-cli/src/commands/self.rs index e2887d4b..cfc62081 100644 --- a/crates/radicle-cli/src/commands/self.rs +++ b/crates/radicle-cli/src/commands/self.rs @@ -1,7 +1,8 @@ use std::ffi::OsString; use radicle::crypto::ssh; -use radicle::Profile; +use radicle::node::Handle as _; +use radicle::{Node, Profile}; use crate::terminal as term; use crate::terminal::args::{Args, Error, Help}; @@ -20,7 +21,6 @@ Options --did Show your DID --alias Show your Node alias - --nid Show your Node ID (NID) --home Show your Radicle home --config Show the location of your configuration file --ssh-key Show your public key in OpenSSH format @@ -100,7 +100,15 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { term::print(profile.config.alias()); } Show::NodeId => { - term::print(profile.id()); + term::warning( + "The option `--nid` is deprecated, please use `rad node status` instead.", + ); + term::print( + Node::new(profile.socket()) + .nid() + .ok() + .unwrap_or_else(|| *profile.id()), + ); } Show::Did => { term::print(profile.did()); @@ -137,11 +145,13 @@ fn all(profile: &Profile) -> anyhow::Result<()> { term::format::tertiary(did).into(), ]); - let node_id = profile.id(); - table.push([ - term::format::style("└╴Node ID (NID)").into(), - term::format::tertiary(node_id).into(), - ]); + let socket = profile.socket(); + let node = if Node::new(&socket).is_running() { + term::format::positive(format!("running ({})", socket.display())) + } else { + term::format::negative("not running".to_string()) + }; + table.push([term::format::style("Node").into(), node.to_string().into()]); let ssh_agent = match ssh::agent::Agent::connect() { Ok(c) => term::format::positive(format!( @@ -158,13 +168,14 @@ fn all(profile: &Profile) -> anyhow::Result<()> { ssh_agent.to_string().into(), ]); - let ssh_short = ssh::fmt::fingerprint(node_id); + let id = profile.id(); + let ssh_short = ssh::fmt::fingerprint(id); table.push([ term::format::style("├╴Key (hash)").into(), term::format::tertiary(ssh_short).into(), ]); - let ssh_long = ssh::fmt::key(node_id); + let ssh_long = ssh::fmt::key(id); table.push([ term::format::style("└╴Key (full)").into(), term::format::tertiary(ssh_long).into(), diff --git a/crates/radicle-cli/src/commands/watch.rs b/crates/radicle-cli/src/commands/watch.rs index a621ac23..6f2b13ca 100644 --- a/crates/radicle-cli/src/commands/watch.rs +++ b/crates/radicle-cli/src/commands/watch.rs @@ -26,7 +26,7 @@ Options --repo The repository to watch (default: `rad .`) --node The namespace under which this reference exists - (default: `rad self --nid`) + (default: NID of the profile) -r, --ref The fully-qualified Git reference (branch, tag, etc.) to watch, eg. 'refs/heads/master' -t, --target The target OID (commit hash) that when reached, diff --git a/rad.1.adoc b/rad.1.adoc index 96bff979..e6233f59 100644 --- a/rad.1.adoc +++ b/rad.1.adoc @@ -115,7 +115,7 @@ For example, to connect to a community node, you can run: The argument given to *connect* is called a node _address_. It is composed of a Node ID (NID), followed by an *@* symbol, and the _host_ name and _port_. -You can display your NID with *rad self --nid*. +You can display your NID with *rad node status*. To make these connections permanent, such that they are always tried on startup, add the addresses to your configuration file at diff --git a/scripts/delete-remote-refs.sh b/scripts/delete-remote-refs.sh deleted file mode 100755 index d1db83f4..00000000 --- a/scripts/delete-remote-refs.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -set -e - -if [ "$#" -lt 2 ]; then - printf "usage: %s \n" "$(basename "$0")" - exit 1 -fi - -RAD_HOME=${RAD_HOME:-"$HOME/.radicle"} -REPO=$(echo "$1" | sed 's/rad://') -REMOTE=$2 - -if [ "$REMOTE" = "$(rad self --nid)" ]; then - echo "Error: refusing to delete your own remote" - exit 1 -fi - -cd "$RAD_HOME/storage/$REPO" - -refs=$(git for-each-ref --format="%(refname)") -pattern="refs/namespaces/$2/refs/*" - -for ref in $refs; do - case "$ref" in - "$pattern" ) - git update-ref -d "$ref" - printf 'Deleted %s\n' "$ref" - ;; - esac -done - -git gc