pub fn print_box(
    id: &str,
    op: &str,
    name: &str,
    status: &[impl AsRef<str>],
    sections: Vec<Vec<Row>>,
) {
    // Terminal size
    let cols = if let Ok(cols) = ::std::env::var("COLUMNS") {
        cols.parse().expect("Can not parse COLUMNS as an integer")
    } else {
        match terminal_size() {
            Some((Width(w), _)) => min(w as usize, 120),
            None => 80,
        }
    };

    // Node identifier
    let mut count = table!([format!("{:^5}", Style::new().bold().paint(id))]);

    count.set_format(format_no_right_border());

    // Content of the table
    let mut right = if status.len() == 1 && status[0].as_ref().len() < 15 {
        build_header(cols, op, name, Some(&status[0]))
    } else {
        build_header_wide(cols, op, name, status)
    };

    for section in sections {
        if section.len() < 1 {
            continue;
        }

        let mut outer = table!();
        outer.set_format(format_none());

        for row in section {
            let mut inner = match row {
                Row::Simple(content) => table!([textwrap::fill(content.as_str(), cols - 30)]),
                Row::Double(header, content) => {
                    table!([format!("{} ", header), textwrap::fill(content.as_str(), cols - 30),])
                }
            };

            inner.set_format(format_none());
            outer.add_row(row![inner]);
        }

        right.add_row(row![outer]);
    }

    // Whole table
    let mut table = table!();
    table.set_format(format_none());
    table.add_row(row![count, right]);
    table.printstd();
}
/// Prints a box containing arbitrary information.
Prints a box containing arbitrary information.
Prints a box containing arbitrary information .
pub fn print_box(
    id: &str,
    op: &str,
    name: &str,
    status: &[impl AsRef<str>],
    sections: Vec<Vec<Row>>,
) {
    // Terminal size
    let cols = if let Ok(cols) = ::std::env::var("COLUMNS") {
        cols.parse().expect("Can not parse COLUMNS as an integer")
    } else {
        match terminal_size() {
            Some((Width(w), _)) => min(w as usize, 120),
            None => 80,
        }
    };
    // Node identifier
    let mut count = table!([format!("{:^5}", Style::new().bold().paint(id))]);
    count.set_format(format_no_right_border());
    // Content of the table
    let mut right = if status.len() == 1 && status[0].as_ref().len() < 15 {
        build_header(cols, op, name, Some(&status[0]))
    } else {
        build_header_wide(cols, op, name, status)
    };
    for section in sections {
        if section.len() < 1 {
            continue;
        }
        let mut outer = table!();
        outer.set_format(format_none());
        for row in section {
            let mut inner = match row {
                Row::Simple(content) => table!([textwrap::fill(content.as_str(), cols - 30)]),
                Row::Double(header, content) => {
                    table!([format!("{} ", header), textwrap::fill(content.as_str(), cols - 30),])
                }
            };
            inner.set_format(format_none());
            outer.add_row(row![inner]);
        }
        right.add_row(row![outer]);
    }
    // Whole table
    let mut table = table!();
    table.set_format(format_none());
    table.add_row(row![count, right]);
    table.printstd();
}
pub fn print_box ( id : & str , op : & str , name : & str , status : & [ impl AsRef < str > ] , sections : Vec < Vec < Row > > , ) { // Terminal size let cols = if let Ok ( cols ) = :: std :: env :: var ( " " ) { cols . parse ( ) . expect ( " " ) } else { match terminal_size ( ) { Some ( ( Width ( w ) , _ ) ) => min ( w as usize , 120 ) , None => 80 , } } ; // Node identifier let mut count = table ! ( [ format ( " " Style new ( ) bold ( ) paint ( id ) ) ] ) ; count . set_format ( format_no_right_border ( ) ) ; // Content of the table let mut right = if status . len ( ) == 1 && status [ 0 ] . as_ref ( ) . len ( ) < 15 { build_header ( cols , op , name , Some ( & status [ 0 ] ) ) } else { build_header_wide ( cols , op , name , status ) } ; for section in sections { if section . len ( ) < 1 { continue ; } let mut outer = table ! ( ) ; outer . set_format ( format_none ( ) ) ; for row in section { let mut inner = match row { Row :: Simple ( content ) => table ! ( [ textwrap fill ( content as_str ( ) cols 30 ) ] ) , Row :: Double ( header , content ) => { table ! ( [ format ( " " header ) textwrap fill ( content as_str ( ) cols 30 ) ] ) } } ; inner . set_format ( format_none ( ) ) ; outer . add_row ( row ! [ inner ] ) ; } right . add_row ( row ! [ outer ] ) ; } // Whole table let mut table = table ! ( ) ; table . set_format ( format_none ( ) ) ; table . add_row ( row ! [ count right ] ) ; table . printstd ( ) ; }
Prints a box containing arbitrary information.
Prints a box containing arbitrary information .
id
&str
op
&str
name
&str
status
&[impl AsRef<str>]
sections
Vec<Vec<Row>>
id
&str
op
&str
name
&str
status
&[impl AsRef<str>]
sections
Vec<Vec<Row>>