cli: Refactor `rad issue list`
Move code into its own method.
This commit is contained in:
parent
e0241050f8
commit
f4dff17085
|
|
@ -9,6 +9,7 @@ use radicle::cob::issue;
|
||||||
use radicle::cob::issue::{CloseReason, Issues, State};
|
use radicle::cob::issue::{CloseReason, Issues, State};
|
||||||
use radicle::node::Handle;
|
use radicle::node::Handle;
|
||||||
use radicle::prelude::Did;
|
use radicle::prelude::Did;
|
||||||
|
use radicle::profile;
|
||||||
use radicle::storage::WriteStorage;
|
use radicle::storage::WriteStorage;
|
||||||
use radicle::{cob, Node};
|
use radicle::{cob, Node};
|
||||||
use radicle_term::table::TableOptions;
|
use radicle_term::table::TableOptions;
|
||||||
|
|
@ -327,6 +328,32 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Operation::List { assigned } => {
|
Operation::List { assigned } => {
|
||||||
|
list(&issues, &profile, &assigned)?;
|
||||||
|
}
|
||||||
|
Operation::Delete { id } => {
|
||||||
|
let id = id.resolve(&repo.backend)?;
|
||||||
|
issues.remove(&id, &signer)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if announce {
|
||||||
|
match node.announce_refs(rid) {
|
||||||
|
Ok(()) => {}
|
||||||
|
Err(e) if e.is_connection_err() => {
|
||||||
|
term::warning("Could not announce issue refs: node is not running");
|
||||||
|
}
|
||||||
|
Err(e) => return Err(e.into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list(
|
||||||
|
issues: &Issues,
|
||||||
|
profile: &profile::Profile,
|
||||||
|
assigned: &Option<Assigned>,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
if issues.is_empty()? {
|
if issues.is_empty()? {
|
||||||
term::print(term::format::italic("Nothing to show."));
|
term::print(term::format::italic("Nothing to show."));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
@ -334,7 +361,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
|
|
||||||
let assignee = match assigned {
|
let assignee = match assigned {
|
||||||
Some(Assigned::Me) => Some(*profile.id()),
|
Some(Assigned::Me) => Some(*profile.id()),
|
||||||
Some(Assigned::Peer(id)) => Some(id.into()),
|
Some(Assigned::Peer(id)) => Some((*id).into()),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -396,22 +423,6 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
t.print();
|
t.print();
|
||||||
}
|
|
||||||
Operation::Delete { id } => {
|
|
||||||
let id = id.resolve(&repo.backend)?;
|
|
||||||
issues.remove(&id, &signer)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if announce {
|
|
||||||
match node.announce_refs(rid) {
|
|
||||||
Ok(()) => {}
|
|
||||||
Err(e) if e.is_connection_err() => {
|
|
||||||
term::warning("Could not announce issue refs: node is not running");
|
|
||||||
}
|
|
||||||
Err(e) => return Err(e.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue