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).
This commit is contained in:
Lorenz Leutgeb 2025-08-27 00:09:37 +02:00 committed by Fintan Halpenny
parent e1af550a09
commit f00d1d6743
6 changed files with 36 additions and 57 deletions

View File

@ -7,7 +7,7 @@ SSH_KEY="$(rad path)/keys/radicle"
main() { main() {
version="$(build/version)" version="$(build/version)"
nid="$(rad self --nid)" nid="$(rad self --did | cut -d: -f3-)"
rad_url="$(rad . | sed s/rad:/rad:\\/\\//)" rad_url="$(rad . | sed s/rad:/rad:\\/\\//)"
rad_remote="$rad_url/$nid" rad_remote="$rad_url/$nid"

View File

@ -3,17 +3,17 @@ device and node.
``` ```
$ rad self $ rad self
Alias alice Alias alice
DID did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi DID did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
└╴Node ID (NID) z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi Node not running
SSH not running SSH not running
├╴Key (hash) SHA256:UIedaL6Cxm6OUErh9GQUzzglSk7VpQlVTI1TAFB/HWA ├╴Key (hash) SHA256:UIedaL6Cxm6OUErh9GQUzzglSk7VpQlVTI1TAFB/HWA
└╴Key (full) ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1 └╴Key (full) ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1
Home [..]/home/alice/.radicle Home [..]/home/alice/.radicle
├╴Config [..]/home/alice/.radicle/config.json ├╴Config [..]/home/alice/.radicle/config.json
├╴Storage [..]/home/alice/.radicle/storage ├╴Storage [..]/home/alice/.radicle/storage
├╴Keys [..]/home/alice/.radicle/keys ├╴Keys [..]/home/alice/.radicle/keys
└╴Node [..]/home/alice/.radicle/node └╴Node [..]/home/alice/.radicle/node
``` ```
If you need to display only your DID, Node ID, or SSH Public Key, you can use 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 $ rad self --nid
! Warning: The option `--nid` is deprecated, please use `rad node status` instead.
z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
``` ```

View File

@ -1,7 +1,8 @@
use std::ffi::OsString; use std::ffi::OsString;
use radicle::crypto::ssh; use radicle::crypto::ssh;
use radicle::Profile; use radicle::node::Handle as _;
use radicle::{Node, Profile};
use crate::terminal as term; use crate::terminal as term;
use crate::terminal::args::{Args, Error, Help}; use crate::terminal::args::{Args, Error, Help};
@ -20,7 +21,6 @@ Options
--did Show your DID --did Show your DID
--alias Show your Node alias --alias Show your Node alias
--nid Show your Node ID (NID)
--home Show your Radicle home --home Show your Radicle home
--config Show the location of your configuration file --config Show the location of your configuration file
--ssh-key Show your public key in OpenSSH format --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()); term::print(profile.config.alias());
} }
Show::NodeId => { 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 => { Show::Did => {
term::print(profile.did()); term::print(profile.did());
@ -137,11 +145,13 @@ fn all(profile: &Profile) -> anyhow::Result<()> {
term::format::tertiary(did).into(), term::format::tertiary(did).into(),
]); ]);
let node_id = profile.id(); let socket = profile.socket();
table.push([ let node = if Node::new(&socket).is_running() {
term::format::style("└╴Node ID (NID)").into(), term::format::positive(format!("running ({})", socket.display()))
term::format::tertiary(node_id).into(), } 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() { let ssh_agent = match ssh::agent::Agent::connect() {
Ok(c) => term::format::positive(format!( Ok(c) => term::format::positive(format!(
@ -158,13 +168,14 @@ fn all(profile: &Profile) -> anyhow::Result<()> {
ssh_agent.to_string().into(), 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([ table.push([
term::format::style("├╴Key (hash)").into(), term::format::style("├╴Key (hash)").into(),
term::format::tertiary(ssh_short).into(), term::format::tertiary(ssh_short).into(),
]); ]);
let ssh_long = ssh::fmt::key(node_id); let ssh_long = ssh::fmt::key(id);
table.push([ table.push([
term::format::style("└╴Key (full)").into(), term::format::style("└╴Key (full)").into(),
term::format::tertiary(ssh_long).into(), term::format::tertiary(ssh_long).into(),

View File

@ -26,7 +26,7 @@ Options
--repo <rid> The repository to watch (default: `rad .`) --repo <rid> The repository to watch (default: `rad .`)
--node <nid> The namespace under which this reference exists --node <nid> The namespace under which this reference exists
(default: `rad self --nid`) (default: NID of the profile)
-r, --ref <ref> The fully-qualified Git reference (branch, tag, etc.) to watch, -r, --ref <ref> The fully-qualified Git reference (branch, tag, etc.) to watch,
eg. 'refs/heads/master' eg. 'refs/heads/master'
-t, --target <oid> The target OID (commit hash) that when reached, -t, --target <oid> The target OID (commit hash) that when reached,

View File

@ -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 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_. 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 To make these connections permanent, such that they are always tried on
startup, add the addresses to your configuration file at startup, add the addresses to your configuration file at

View File

@ -1,33 +0,0 @@
#!/bin/sh
set -e
if [ "$#" -lt 2 ]; then
printf "usage: %s <rid> <nid>\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