Compare commits

...

2 commits

Author SHA1 Message Date
0179c53e82 Merge branch 'feat/cli' of https://git.cscherr.de/PlexSheep/pt into feat/cli
All checks were successful
cargo devel CI / cargo CI (push) Successful in 1m55s
2024-06-27 22:22:49 +02:00
08bfc03628 refactor(cli::printing): use Option<Color> for blockfmt_advanced
Users might just need the cell String, not a colored one.
2024-06-27 22:22:46 +02:00

View file

@ -42,7 +42,7 @@ pub fn blockprint(content: impl ToString, color: Color) {
pub fn blockfmt(content: impl ToString, color: Color) -> String { pub fn blockfmt(content: impl ToString, color: Color) -> String {
blockfmt_advanced( blockfmt_advanced(
content, content,
color, Some(color),
presets::UTF8_BORDERS_ONLY, presets::UTF8_BORDERS_ONLY,
ContentArrangement::DynamicFullWidth, ContentArrangement::DynamicFullWidth,
CellAlignment::Center, CellAlignment::Center,
@ -67,7 +67,7 @@ pub fn blockfmt(content: impl ToString, color: Color) -> String {
/// "{}", /// "{}",
/// blockfmt_advanced( /// blockfmt_advanced(
/// "Hello world!".to_string(), /// "Hello world!".to_string(),
/// Color::Blue, /// Some(Color::Blue),
/// presets::UTF8_FULL, /// presets::UTF8_FULL,
/// ContentArrangement::DynamicFullWidth, /// ContentArrangement::DynamicFullWidth,
/// CellAlignment::Center /// CellAlignment::Center
@ -86,7 +86,7 @@ pub fn blockfmt(content: impl ToString, color: Color) -> String {
/// ///
pub fn blockfmt_advanced( pub fn blockfmt_advanced(
content: impl ToString, content: impl ToString,
color: Color, color: Option<Color>,
preset: &str, preset: &str,
arrangement: ContentArrangement, arrangement: ContentArrangement,
alignment: CellAlignment, alignment: CellAlignment,
@ -98,5 +98,8 @@ pub fn blockfmt_advanced(
.add_row(vec![content.to_string()]); .add_row(vec![content.to_string()]);
table.column_mut(0).unwrap().set_cell_alignment(alignment); table.column_mut(0).unwrap().set_cell_alignment(alignment);
format!("{}", style(table).fg(color)) match color {
Some(c) => format!("{}", style(table).fg(c)),
None => table.to_string(),
}
} }