11 releases (stable)

1.3.1 Feb 29, 2020
1.3.0 Feb 8, 2020
1.1.3 Dec 15, 2019
0.2.0 Dec 8, 2019
0.1.1 Sep 8, 2019

#111 in Command-line interface

Download history 10/week @ 2021-02-24 9/week @ 2021-03-03 8/week @ 2021-03-10 7/week @ 2021-03-17 42/week @ 2021-03-24 17/week @ 2021-03-31 19/week @ 2021-04-07 29/week @ 2021-04-14 43/week @ 2021-04-21 14/week @ 2021-04-28 12/week @ 2021-05-05 28/week @ 2021-05-12 10/week @ 2021-05-19 17/week @ 2021-05-26 11/week @ 2021-06-02 21/week @ 2021-06-09

91 downloads per month
Used in jobrog

MIT license

275KB
961 lines

colonnade

tabular text

         Colonnade lets     As you can see, it supports text     If you want to 
        you format text      alignment, viewport width, and      colorize your  
            in columns.              column widths.              table, you'll  
                                                                 need to use the
                                                                 macerate       
                                                                 method.        

                           Two or more rows of columns makes                    
                                        a table.                                

USAGE

extern crate colonnade;
use colonnade::{Alignment, Colonnade};

#[allow(unused_must_use)]
fn main() {
    // text to put in tabular form
    let text = vec![
        vec![
            "Colonnade lets you format text in columns.",
            "As you can see, it supports text alignment, viewport width, and column widths.",
            "If you want to colorize your table, you'll need to use the macerate method.",
        ],
        vec!["", "Two or more rows of columns makes a table.", ""],
    ];
    let mut colonnade = Colonnade::new(3, 80).unwrap(); // 3 columns of text in an 80-character viewport

    // configure the table a bit
    colonnade.left_margin(4);
    colonnade.columns[0].left_margin(8); // the first column should have a left margin 8 spaces wide
    colonnade.fixed_width(15);
    colonnade.columns[0].clear_limits(); // the central column has no fixed size limits
    colonnade.columns[0].alignment(Alignment::Right);
    colonnade.columns[1].alignment(Alignment::Center);
    colonnade.spaces_between_rows(1);    // add a blank link between rows

    // now print out the table
    for line in colonnade.tabulate(&text).unwrap() {
        println!("{}", line);
    }
}

This produces the text at the top of the page.

For further details see the documentation on docs.rs.

Dependencies

~480–780KB
~13K SLoC