From a6d59b3c0eeafe2d6fdff4b58e067c087c552a71 Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Wed, 21 Dec 2022 08:47:01 -0500 Subject: [PATCH] cli: alter use subcommands for patch Make `rad patch` accept subcommands for specifying its operation in place of the '--command' notation. For instance `rad patch update` versus `rad patch --update`. Also make the default operation list active patches, replacing patch creation. Patch creation is now done via `rad patch open`. Make these changes in a way consistent with other commands like `rad delegate`. Add '--no-confirm' to patch to support this subcommand's documentation test. Signed-off-by: Slack Coder --- radicle-cli/examples/rad-patch.md | 65 +++++++++++ radicle-cli/src/commands/patch.rs | 139 ++++++++++++++++------- radicle-cli/src/commands/patch/create.rs | 38 ++++--- radicle-cli/tests/commands.rs | 18 +++ 4 files changed, 204 insertions(+), 56 deletions(-) create mode 100644 radicle-cli/examples/rad-patch.md diff --git a/radicle-cli/examples/rad-patch.md b/radicle-cli/examples/rad-patch.md new file mode 100644 index 00000000..d6a6f19a --- /dev/null +++ b/radicle-cli/examples/rad-patch.md @@ -0,0 +1,65 @@ +When contributing to another's project, it is common for the contribution to be +of many commits and involve a discussion with the project's maintainer. This is supported +via Radicle's patches. + +Here we give a brief overview for using patches in our hypothetical car +scenario. It turns out instructions containing the power requirements were +missing from the project. + +``` +$ git checkout -b flux-capacitor-power +$ touch README.md +``` + +Here the instructions are added to the project's README for 1.21 gigawatts and +commit the changes to git. + +``` +$ git add README.md +$ git commit -m "Define power requirements" +[flux-capacitor-power 7939a9e] Define power requirements + 1 file changed, 0 insertions(+), 0 deletions(-) + create mode 100644 README.md +``` + +Once the code is ready, we open (or create) a patch with our changes for the project. + +``` +$ rad patch open --message "define power requirements" --no-confirm + +🌱 Creating patch for heartwood + +ok Pushing HEAD to storage... +ok Analyzing remotes... + +z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi/master (cdf76ce) <- z6MknSL…StBU8Vi/flux-capacitor-power (7939a9e) +1 commit(s) ahead, 0 commit(s) behind + +7939a9e Define power requirements + + +╭─ define power requirements ─────── + +No description provided. + +╰─────────────────────────────────── + + +ok Patch 3b1f58414e51266d7621203554a63eaee242b744 created 🌱 +``` + +It will now be listed as one of the project's open patches. + +``` +$ rad patch + + YOU PROPOSED + +define power requirements 3b1f58414e5 R0 7939a9e (flux-capacitor-power) ahead 1, behind 0 +└─ * opened by z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (you) [..] + + OTHERS PROPOSED + +Nothing to show. + +``` diff --git a/radicle-cli/src/commands/patch.rs b/radicle-cli/src/commands/patch.rs index b9282b1c..4bb644ef 100644 --- a/radicle-cli/src/commands/patch.rs +++ b/radicle-cli/src/commands/patch.rs @@ -24,11 +24,13 @@ pub const HELP: Help = Help { usage: r#" Usage - rad patch [