Unicode tables for the command line, designed for MoonBit
Dependencies
moon add chensuiyi/clitablelet table = @clitable.Table::new([
@clitable.Column::new("Name"),
@clitable.Column::new("Age").align(@clitable.Right),
]).push_rows([["Alice", "24"], ["Bob", "30"]])
println(table)┌───────┬─────┐
│ Name │ Age │
├───────┼─────┤
│ Alice │ 24 │
├───────┼─────┤
│ Bob │ 30 │
└───────┴─────┘Table::new(cols).with_chars(@clitable.Chars::rounded())Table::new(cols).with_width(80)@clitable.Table::grid([["a", "b"], ["c", "d"]])@clitable.Table::kv([("Name", "Alice"), ("Age", "24")])Table::new(cols).push([
@clitable.Cell::text("greetings").span(2),
@clitable.Cell::text("sup").span(2, rows=2),
])@clitable.Cell::text("文档").link("https://mooncakes.io")Table::new(cols).with_row_height(2)impl @clitable.ToRow for User with to_row(self) {
[@clitable.Cell::text(self.name), @clitable.Cell::text(self.age.to_string())]
}
Table::new(cols).push_rows(users)pub suberror TableError {
Arity(Int, Int)
TooNarrow(Int)
}pub struct Chars {
top : String
top_mid : String
top_left : String
top_right : String
bottom : String
bottom_mid : String
bottom_left : String
bottom_right : String
left : String
left_mid : String
mid : String
mid_mid : String
right : String
right_mid : String
middle : String
} derive(Debug)fn truncate_to(text : String, width : Int, symbol : String) -> StringInstall
Download zipUnicode tables for the command line, designed for MoonBit
Dependencies