cli: Show a message when there are no issues to display

This commit fixes the inconsistency with the `rad patch` command,
which previously displayed an empty table when there were no issues. Now,
the CLI will display a message indicating that there are no issues to display.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
Vincenzo Palazzo 2023-04-26 00:55:21 +02:00
parent 3ea7541d55
commit 8d1bf9e997
No known key found for this signature in database
GPG Key ID: 8B6DC2B870B80D5F
2 changed files with 10 additions and 0 deletions

View File

@ -325,6 +325,11 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
}
}
Operation::List { assigned } => {
if issues.is_empty()? {
term::print(term::format::italic("Nothing to show."));
return Ok(());
}
let assignee = match assigned {
Some(Assigned::Me) => Some(*profile.id()),
Some(Assigned::Peer(id)) => Some(id.into()),

View File

@ -223,6 +223,11 @@ where
}))
}
/// Return true if the list of issues is empty.
pub fn is_empty(&self) -> Result<bool, Error> {
Ok(self.count()? == 0)
}
/// Return objects count.
pub fn count(&self) -> Result<usize, Error> {
let raw = cob::list(self.repo, T::type_name())?;