From 6578fedfbbdbe783e81ebf00858b6ceeb920cb17 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Tue, 6 Jun 2023 10:48:04 +0200 Subject: [PATCH] cli: Add issue id to `show_issue` function Signed-off-by: Sebastian Martinez --- radicle-cli/examples/rad-issue.md | 2 ++ radicle-cli/examples/rad-tag.md | 2 ++ radicle-cli/examples/workflow/3-issues.md | 2 ++ radicle-cli/src/commands/issue.rs | 15 ++++++++++----- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/radicle-cli/examples/rad-issue.md b/radicle-cli/examples/rad-issue.md index 1d9c1276..6b6bc172 100644 --- a/radicle-cli/examples/rad-issue.md +++ b/radicle-cli/examples/rad-issue.md @@ -7,6 +7,7 @@ Let's say the new car you are designing with your peers has a problem with its f $ rad issue open --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply" --no-announce ╭─────────────────────────────────────────────────────────╮ │ Title flux capacitor underpowered │ +│ Issue 2e8c1bf3fe0532a314778357c886608a966a34bd │ │ Status open │ │ │ │ Flux capacitor power requirements exceed current supply │ @@ -30,6 +31,7 @@ Show the issue information issue. $ rad issue show 2e8c1bf ╭─────────────────────────────────────────────────────────╮ │ Title flux capacitor underpowered │ +│ Issue 2e8c1bf3fe0532a314778357c886608a966a34bd │ │ Status open │ │ │ │ Flux capacitor power requirements exceed current supply │ diff --git a/radicle-cli/examples/rad-tag.md b/radicle-cli/examples/rad-tag.md index 453c6062..2c3733e0 100644 --- a/radicle-cli/examples/rad-tag.md +++ b/radicle-cli/examples/rad-tag.md @@ -11,6 +11,7 @@ We can now show the issue to check whether those tags were added: $ rad issue show 2e8c1bf3fe0532a314778357c886608a966a34bd ╭─────────────────────────────────────────────────────────╮ │ Title flux capacitor underpowered │ +│ Issue 2e8c1bf3fe0532a314778357c886608a966a34bd │ │ Tags bug, good-first-issue │ │ Status open │ │ │ @@ -30,6 +31,7 @@ Notice that the `good-first-issue` tag has disappeared: $ rad issue show 2e8c1bf3fe0532a314778357c886608a966a34bd ╭─────────────────────────────────────────────────────────╮ │ Title flux capacitor underpowered │ +│ Issue 2e8c1bf3fe0532a314778357c886608a966a34bd │ │ Tags bug │ │ Status open │ │ │ diff --git a/radicle-cli/examples/workflow/3-issues.md b/radicle-cli/examples/workflow/3-issues.md index c4968b50..cf317437 100644 --- a/radicle-cli/examples/workflow/3-issues.md +++ b/radicle-cli/examples/workflow/3-issues.md @@ -7,6 +7,7 @@ Let's say the new car you are designing with your peers has a problem with its f $ rad issue open --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply" --no-announce ╭─────────────────────────────────────────────────────────╮ │ Title flux capacitor underpowered │ +│ Issue b05e945bb63c11bf80320f4e26ad1d1f7c51f755 │ │ Status open │ │ │ │ Flux capacitor power requirements exceed current supply │ @@ -52,6 +53,7 @@ In addition, you can see that when you run `rad issue show` you are listed under $ rad issue show b05e945 ╭─────────────────────────────────────────────────────────╮ │ Title flux capacitor underpowered │ +│ Issue b05e945bb63c11bf80320f4e26ad1d1f7c51f755 │ │ Assignees z6Mkt67…v4N1tRk │ │ Status open │ │ │ diff --git a/radicle-cli/src/commands/issue.rs b/radicle-cli/src/commands/issue.rs index 76c5c4a0..68d356ed 100644 --- a/radicle-cli/src/commands/issue.rs +++ b/radicle-cli/src/commands/issue.rs @@ -284,7 +284,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { } => { let issue = issues.create(title, description, tags.as_slice(), &[], &signer)?; if !options.quiet { - show_issue(&issue)?; + show_issue(&issue, issue.id())?; } } Operation::Show { id } => { @@ -292,7 +292,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let issue = issues .get(&id)? .context("No issue with the given ID exists")?; - show_issue(&issue)?; + show_issue(&issue, &id)?; } Operation::State { id, state } => { let id = id.resolve(&repo.backend)?; @@ -536,7 +536,7 @@ fn open( signer, )?; if !options.quiet { - show_issue(&issue)?; + show_issue(&issue, issue.id())?; } Ok(()) @@ -618,12 +618,12 @@ fn edit( Ok(()) })?; - show_issue(&issue)?; + show_issue(&issue, &id)?; Ok(()) } -fn show_issue(issue: &issue::Issue) -> anyhow::Result<()> { +fn show_issue(issue: &issue::Issue, id: &cob::ObjectId) -> anyhow::Result<()> { let tags: Vec = issue.tags().cloned().map(|t| t.into()).collect(); let assignees: Vec = issue .assigned() @@ -640,6 +640,11 @@ fn show_issue(issue: &issue::Issue) -> anyhow::Result<()> { term::format::bold(issue.title().to_owned()), ]); + attrs.push([ + term::format::tertiary("Issue".to_owned()), + term::format::bold(id.to_string()), + ]); + if !tags.is_empty() { attrs.push([ term::format::tertiary("Tags".to_owned()),