Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
cli: idempotent `rad id update`
Merged fintohaps opened 1 year ago

Instead of producing an error when there is no update during rad id update, a warning is issued with helpful tips. The command is considered is still considered successful.

3 files changed +11 -13 42ffbf3f 80f1e651
modified radicle-cli/examples/rad-id-private.md
@@ -62,17 +62,16 @@ $ rad id update --title "Remove allow list" --description "" --allow did:key:z6M
✗ Error: `--allow` and `--disallow` must not overlap: ["did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk"]
```

-
Allowing or disallowing the same peer twice will result in an error the second
-
call, since there is no update specified:
+
Allowing or disallowing the same peer twice will result in a message saying that
+
the document is already up to date:

```
$ rad id update --title "Allow Bob" --description "" --allow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk -q
...
```
-
``` (fails)
+
```
$ rad id update --title "Allow Bob" --description "" --allow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk -q
-
✗ Error: no update specified
-
✗ Hint: an update to the identity must be specified, run `rad id update -h` to see the available options
+
Nothing to do. The document is up to date. See `rad inspect --identity`
```

If we attempt to change the list while also changing the repository to `public`,
modified radicle-cli/examples/rad-id.md
@@ -174,10 +174,9 @@ $ rad id accept 0ca42d376bd566631083c8913cf86bec722da392
✗ Error: [..]
```

-
If no updates are specified then the update will fail:
+
If no updates are specified then we are told that our command had no effect:

-
``` (fail)
+
```
$ rad id update --title "Update canonical branch" --description "Update the canonical branch to `main`"
-
✗ Error: no update specified
-
✗ Hint: an update to the identity must be specified, run `rad id update -h` to see the available options
+
Nothing to do. The document is up to date. See `rad inspect --identity`
```
modified radicle-cli/src/commands/id.rs
@@ -470,10 +470,10 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
                proposal
            };
            if proposal == current.doc {
-
                return Err(Error::WithHint {
-
                    err: anyhow!("no update specified"),
-
                    hint: "an update to the identity must be specified, run `rad id update -h` to see the available options"
-
                }.into());
+
                term::print(term::format::italic(
+
                    "Nothing to do. The document is up to date. See `rad inspect --identity`",
+
                ));
+
                return Ok(());
            }
            let revision = update(title, description, proposal, &mut identity, &signer)?;