pub struct TableBuilder { /* private fields */ }Expand description
Builder for constructing tables with a fluent API.
Provides methods for configuring table appearance, columns, and behavior before building the final table.
§Examples
use sublime_cli_tools::output::table::{TableBuilder, TableTheme, ColumnAlignment};
let mut table = TableBuilder::new()
.theme(TableTheme::Default)
.columns(&["Name", "Version", "Type"])
.alignment(1, ColumnAlignment::Right)
.max_width(100)
.build();
table.add_row(&["package", "1.0.0", "major"]);Implementations§
Source§impl TableBuilder
impl TableBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new table builder with default settings.
§Examples
use sublime_cli_tools::output::table::TableBuilder;
let builder = TableBuilder::new();Sourcepub fn theme(self, theme: TableTheme) -> Self
pub fn theme(self, theme: TableTheme) -> Self
Sets the table theme.
§Examples
use sublime_cli_tools::output::table::{TableBuilder, TableTheme};
let builder = TableBuilder::new().theme(TableTheme::Minimal);Sourcepub fn columns(self, columns: &[&str]) -> Self
pub fn columns(self, columns: &[&str]) -> Self
Sets the column headers.
§Examples
use sublime_cli_tools::output::table::TableBuilder;
let builder = TableBuilder::new()
.columns(&["Package", "Version", "Type"]);Sourcepub fn alignment(self, column_index: usize, alignment: ColumnAlignment) -> Self
pub fn alignment(self, column_index: usize, alignment: ColumnAlignment) -> Self
Sets the alignment for a specific column.
§Arguments
column_index- Zero-based column indexalignment- The alignment to apply
§Examples
use sublime_cli_tools::output::table::{TableBuilder, ColumnAlignment};
let builder = TableBuilder::new()
.columns(&["Name", "Count"])
.alignment(1, ColumnAlignment::Right);Sourcepub fn max_width(self, width: usize) -> Self
pub fn max_width(self, width: usize) -> Self
Sets the maximum table width in characters.
If not set, the terminal width is used automatically.
§Examples
use sublime_cli_tools::output::table::TableBuilder;
let builder = TableBuilder::new().max_width(100);Sourcepub fn min_column_width(self, width: usize) -> Self
pub fn min_column_width(self, width: usize) -> Self
Sets the minimum column width in characters.
Columns will not be narrower than this width unless the terminal is too narrow. Default is 10.
§Examples
use sublime_cli_tools::output::table::TableBuilder;
let builder = TableBuilder::new().min_column_width(15);Trait Implementations§
Source§impl Debug for TableBuilder
impl Debug for TableBuilder
Auto Trait Implementations§
impl Freeze for TableBuilder
impl RefUnwindSafe for TableBuilder
impl Send for TableBuilder
impl Sync for TableBuilder
impl Unpin for TableBuilder
impl UnwindSafe for TableBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more