diff --git a/radicle-cli/src/commands/seed.rs b/radicle-cli/src/commands/seed.rs index 9dde69ec..397ac16a 100644 --- a/radicle-cli/src/commands/seed.rs +++ b/radicle-cli/src/commands/seed.rs @@ -176,7 +176,7 @@ pub fn delete(rid: RepoId, node: &mut Node, profile: &Profile) -> anyhow::Result pub fn seeding(profile: &Profile) -> anyhow::Result<()> { let store = profile.policies()?; let mut t = term::Table::new(term::table::TableOptions::bordered()); - t.push([ + t.header([ term::format::default(String::from("RID")), term::format::default(String::from("Scope")), term::format::default(String::from("Policy")), @@ -199,7 +199,12 @@ pub fn seeding(profile: &Profile) -> anyhow::Result<()> { term::format::secondary(policy), ]) } - t.print(); + + if t.is_empty() { + term::print(term::format::dim("No seeding policies to show.")); + } else { + t.print(); + } Ok(()) } diff --git a/radicle-term/src/table.rs b/radicle-term/src/table.rs index 3802b127..a4137682 100644 --- a/radicle-term/src/table.rs +++ b/radicle-term/src/table.rs @@ -56,6 +56,7 @@ impl TableOptions { #[derive(Debug)] enum Row { + Header([T; W]), Data([T; W]), Divider, } @@ -104,7 +105,7 @@ where let mut line = Line::default(); match row { - Row::Data(cells) => { + Row::Header(cells) | Row::Data(cells) => { if let Some(color) = border { line.push(Paint::new("│ ").fg(color)); } @@ -178,6 +179,13 @@ impl Table { self.rows.push(Row::Data(row)); } + pub fn header(&mut self, row: [T; W]) { + for (i, cell) in row.iter().enumerate() { + self.widths[i] = self.widths[i].max(cell.width()); + } + self.rows.push(Row::Header(row)); + } + pub fn extend(&mut self, rows: impl IntoIterator) { for row in rows.into_iter() { self.push(row);