Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
- aarch64-apple-darwin
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-20.04
runner: ubuntu-22.04
- target: aarch64-apple-darwin
runner: macos-14

Expand Down
15 changes: 15 additions & 0 deletions doc/src/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Release notes

## 0.5.0 (not yet released)

*Highlights:*

**Row** 0.5 improves the user interface and updates the code to meet modern
Rust standards.

The subcommands `show directories`, `show jobs`, and `show status` now report
`No matches.` when there are no results to show.

*Changed:*

* Writing tabular output with no rows now results in the output `No matches.`.
* Build executables on Ubuntu 22.04.

## 0.4.0 (2024-12-06)

*Highlights:*
Expand Down
9 changes: 9 additions & 0 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,29 @@ impl<T: Write> Drop for MultiProgressWriter<T> {
}
}

#[derive(Clone, Debug, PartialEq)]
pub(crate) enum Alignment {
Left,
Right,
}

/// One item in a table.
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct Item {
text: String,
style: Style,
alignment: Alignment,
}

/// A table row is either a separator or a vector of items.
#[derive(Clone, Debug, PartialEq)]
pub(crate) enum Row {
Separator,
Items(Vec<Item>),
}

/// The table
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct Table {
// The header row.
pub header: Vec<Item>,
Expand Down Expand Up @@ -154,6 +158,11 @@ impl Table {
}

pub(crate) fn write<W: Write>(&self, writer: &mut W) -> io::Result<()> {
if self.rows.is_empty() || self.rows.len() == 1 && self.rows[0] == Row::Separator {
writeln!(writer, "No matches.")?;
return Ok(());
}

let mut column_width: Vec<usize> = self
.header
.iter()
Expand Down