Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
Multiprofile: Profile management for Radicle CLI
Draft did:key:z6MkihpD...TvYG opened 8 months ago

This change introduces a first-class profile management command to the Radicle CLI, enabling clean separation and safe switching of per-user configuration and keys by copying selected profile data into the root ~/.radicle/ directory (no symlinks).

Summary

  • New command: rad profile
  • Subcommands: new, switch, list, current, remove
  • new: creates profiles/, activates it, and clears the root so rad auth can initialize cleanly
  • switch: saves current root back to the active profile; then copies the target profile’s config.json and keys/* into ~/.radicle/
  • Replace-in-place copy semantics to avoid partial states; cross-platform behavior

Documentation

  • crates/radicle-cli/examples/rad-profile.md
did:key:z6MkihpD...TvYG opened with revision 9702eda6 on base 55cdd880 +352 -0 8 months ago

This change introduces a first-class profile management command to the Radicle CLI, enabling clean separation and safe switching of per-user configuration and keys by copying selected profile data into the root ~/.radicle/ directory (no symlinks).

Summary

  • New command: rad profile
  • Subcommands: new, switch, list, current, remove
  • new: creates profiles/, activates it, and clears the root so rad auth can initialize cleanly
  • switch: saves current root back to the active profile; then copies the target profile’s config.json and keys/* into ~/.radicle/
  • Replace-in-place copy semantics to avoid partial states; cross-platform behavior

Documentation

  • crates/radicle-cli/examples/rad-profile.md
did:key:z6MkihpD...TvYG commented on revision 1 8 months ago

Suggested labels: cli, feature, profiles

did:key:z6MkgFq6...nBGz reviewed · 4 comments 8 months ago

Looks very good in general! I’ve left some comments though. CI needs to be fixed. It is failing with Action failed: command failed: ["cargo", "fmt", "--check"].

did:key:z6MkgFq6...nBGz commented on revision 1 8 months ago

Hey there, thanks a lot for your contribution!

That’s a very nice addition. I did a first review run on the initial revision and it looks good so far, but I’d need to spend some more time reviewing and testing it. Maybe we could already tackle the comments? Please feel free to also reach out on Zulip!

did:key:z6MkihpD...TvYG pushed revision 2 d08d2489 on base 55cdd880 +445 -0 8 months ago

cli(profile): isolated profiles; copy-on-switch; explicit default

Introduce first-class profile management for the Radicle CLI.

Features

  • Command: rad profile
  • Subcommands: • new [–from ] [–force] • switch <name|default> [–print-env] • list | current | remove [-y]

Semantics

  • Always show ‘default’ in listings; ‘current’ prints ‘default’ when no active profile is set.
  • switch persists the current root back to the active profile, then copies the target profile’s config.json and keys/* into ~/.radicle/.
  • switch default persists the current root (if any), clears ~/.radicle/ (config.json, keys/), and unsets the active profile marker; with –print-env it emits ‘unset RAD_PROFILE’.
  • new clears the root so ‘rad auth’ can initialize cleanly.

Implementation

  • No symlinks; replace-in-place copy to avoid partial states (portable).
  • Robust RAD_HOME resolution (works before ‘rad auth’).
  • Dedicated errors with thiserror; clippy/fmt clean.

Docs

  • crates/radicle-cli/examples/rad-profile.md
did:key:z6MkihpD...TvYG commented on revision 1 8 months ago

okay, thank you for coming back. I’m making the changes you requested.

lorenz commented on revision 1 8 months ago

That’s a very nice addition.

How does this affect the node vs. user? I just skimmed this, and it appears that since it also copies the configuration, it also affects the configuration of the node.

I proposed a long time ago, see patch ed450c98018617 to make the key location used for radicle-node to be variable, and in that patch I add a configuration option to $RAD_HOME/config.json to set the key location for the node.

Do not get me wrong, I would love a command that changes the user identity like is proposed here, but I would like to be sure to understand how it fits into node vs. user.

levitte reviewed 7 months ago

Reading the description, I gotta admit that I get worried by all the copying of stuff. I would much rather have a simple profile file (~/.radicle.profile, perhaps?) that holds paths to the profile’s config.json and keys directory, and avoid all the copying.

My reason for worry is that any program can break, and if there’s a break while copying is going on, it will leave ~/.radicle in an inconsistent state. That’s a very big risk.

did:key:z6MkihpD...TvYG commented on revision 2 7 months ago

Yes, I understand your concern, and you are right. So far, it hasn’t caused any problems (I’ve been using it myself). Still, your concern is understandable. I plan to rewrite the code in a more professional way in the future.