From 4cced3ddb802d04c982d1833b8bbb39621b93228 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Mon, 16 Sep 2024 13:40:39 +0100 Subject: [PATCH] cli: add remaining patch actions Add the remaining `Patch` actions to the CLI interface. These include: - React to a revision - Edit a comment - React to a comment - Redact a comment The `react` subcommand is added in a straight-forward manner. The comment commands are slightly less straight-forward. In order to keep to one layer of subcommands, these variants are done through the `rad patch comment` subcommand. They are accessed via options: `--edit`, `--react`, and `--redact`, respectively. Each of these options takes the `CommentId` for which the action is affecting. The `message`, `react` (introduced for `rad patch react`), and `undo` variables repurposed for this subset of actions. --- radicle-cli/examples/rad-patch.md | 17 ++ radicle-cli/src/commands/patch.rs | 174 +++++++++++++++++- radicle-cli/src/commands/patch/comment.rs | 7 + .../src/commands/patch/comment/edit.rs | 49 +++++ .../src/commands/patch/comment/react.rs | 38 ++++ .../src/commands/patch/comment/redact.rs | 36 ++++ radicle-cli/src/commands/patch/common.rs | 1 + radicle-cli/src/commands/patch/react.rs | 35 ++++ 8 files changed, 353 insertions(+), 4 deletions(-) create mode 100644 radicle-cli/src/commands/patch/comment/edit.rs create mode 100644 radicle-cli/src/commands/patch/comment/react.rs create mode 100644 radicle-cli/src/commands/patch/comment/redact.rs create mode 100644 radicle-cli/src/commands/patch/common.rs create mode 100644 radicle-cli/src/commands/patch/react.rs diff --git a/radicle-cli/examples/rad-patch.md b/radicle-cli/examples/rad-patch.md index 54b77ce9..503fa738 100644 --- a/radicle-cli/examples/rad-patch.md +++ b/radicle-cli/examples/rad-patch.md @@ -143,6 +143,23 @@ $ rad patch comment aa45913 --message 'My favorite decade!' --reply-to 686ec1c - f4336e42daf76342f787d574b5ee779d89d05c7a ``` +If we realize we made a mistake in the comment, we can go back and edit it: + +``` +$ rad patch comment aa45913 --edit 686ec1c --message 'I cannot wait to get back to the 80s!' --no-announce +╭───────────────────────────────────────╮ +│ alice (you) now 686ec1c │ +│ I cannot wait to get back to the 80s! │ +╰───────────────────────────────────────╯ +``` + +And if we really made a mistake, then we can redact the comment entirely: + +``` +$ rad patch comment aa45913 --redact f4336e4 --no-announce +✓ Redacted comment f4336e42daf76342f787d574b5ee779d89d05c7a +``` + Now, let's checkout the patch that we just created: ``` diff --git a/radicle-cli/src/commands/patch.rs b/radicle-cli/src/commands/patch.rs index c2bfc9c3..97fea51b 100644 --- a/radicle-cli/src/commands/patch.rs +++ b/radicle-cli/src/commands/patch.rs @@ -18,6 +18,8 @@ mod edit; mod label; #[path = "patch/list.rs"] mod list; +#[path = "patch/react.rs"] +mod react; #[path = "patch/ready.rs"] mod ready; #[path = "patch/redact.rs"] @@ -33,11 +35,12 @@ mod update; use std::collections::BTreeSet; use std::ffi::OsString; +use std::str::FromStr as _; use anyhow::anyhow; use radicle::cob::patch::PatchId; -use radicle::cob::{patch, Label}; +use radicle::cob::{patch, Label, Reaction}; use radicle::git::RefString; use radicle::patch::cache::Patches as _; use radicle::storage::git::transport; @@ -67,6 +70,7 @@ Usage rad patch resolve [--review ] [--comment ] [--unresolve] [