pub fn print_banner(commands: Vec<String>, chunk_size: i32) {
    let chunks: Vec<Vec<String>> = commands.chunks(chunk_size as usize).map(|x| x.to_vec()).collect();
    let mut cell_sizes = Vec::new();

    let mut row_cell_count: i32 = 0;
    let mut command_data: Vec<Vec<String>> = Vec::new();
    for chunk in chunks {
        let mut cells: Vec<String> = Vec::new();
        for item in chunk {
            cells.push(item.clone());
            cell_sizes.push(item.chars().count());
            row_cell_count += 1;
        }
        if row_cell_count < chunk_size {
            while row_cell_count < chunk_size {
                cells.push(" ".to_string());
                cell_sizes.push(1);
                row_cell_count += 1;
            }
        } else {
            row_cell_count = 0;
        }
        command_data.push(cells);
    }

    let row_cell_sizes: Vec<Vec<usize>> = cell_sizes.chunks(chunk_size as usize).map(|x| x.to_vec()).collect();
    let mut row_cell_size = Vec::new();
    let mut max_cell_size: usize = 0;
    for sizes in row_cell_sizes {
        for size in sizes {
            if size > max_cell_size {
                max_cell_size = size;
            }
        }
        row_cell_size.push(max_cell_size);
        max_cell_size = 0;
    }

    let banner = include!("../assets/tari_banner.rs");
    let target_line_length = multiline_find_display_length(banner);
    for line in banner.lines() {
        println!("{}", line.to_string());
    }
    println!("\n{}", box_line(target_line_length, true));
    let logo = include!("../assets/tari_logo.rs");
    for line in logo.lines() {
        println!("{}", box_data(line.to_string(), target_line_length));
    }
    println!("{}", box_data(" ".to_string(), target_line_length));
    println!("{}", box_data("Tari Base Node".to_string(), target_line_length));
    println!("{}", box_data("~~~~~~~~~~~~~~".to_string(), target_line_length));
    println!(
        "{}",
        box_data(
            format!("Copyright 2019-{}. {}", Utc::now().year(), consts::APP_AUTHOR),
            target_line_length
        )
    );
    println!(
        "{}",
        box_data(format!("Version {}", consts::APP_VERSION), target_line_length)
    );
    println!("{}", box_separator(target_line_length));
    println!("{}", box_data("Commands".to_string(), target_line_length));
    println!("{}", box_data("~~~~~~~~".to_string(), target_line_length));
    println!("{}", box_separator(target_line_length));
    let rows = box_tabular_data_rows(command_data, row_cell_size, target_line_length, 10);
    for row in rows {
        println!("{}", row);
    }
    println!("{}", box_line(target_line_length, false));
}
/// Prints a pretty banner on the console as well as the list of available commands
Prints a pretty banner on the console as well as the list of available commands
Prints a pretty banner on the console as well as the list of available commands
pub fn print_banner(commands: Vec<String>, chunk_size: i32) {
    let chunks: Vec<Vec<String>> = commands.chunks(chunk_size as usize).map(|x| x.to_vec()).collect();
    let mut cell_sizes = Vec::new();
    let mut row_cell_count: i32 = 0;
    let mut command_data: Vec<Vec<String>> = Vec::new();
    for chunk in chunks {
        let mut cells: Vec<String> = Vec::new();
        for item in chunk {
            cells.push(item.clone());
            cell_sizes.push(item.chars().count());
            row_cell_count += 1;
        }
        if row_cell_count < chunk_size {
            while row_cell_count < chunk_size {
                cells.push(" ".to_string());
                cell_sizes.push(1);
                row_cell_count += 1;
            }
        } else {
            row_cell_count = 0;
        }
        command_data.push(cells);
    }
    let row_cell_sizes: Vec<Vec<usize>> = cell_sizes.chunks(chunk_size as usize).map(|x| x.to_vec()).collect();
    let mut row_cell_size = Vec::new();
    let mut max_cell_size: usize = 0;
    for sizes in row_cell_sizes {
        for size in sizes {
            if size > max_cell_size {
                max_cell_size = size;
            }
        }
        row_cell_size.push(max_cell_size);
        max_cell_size = 0;
    }
    let banner = include!("../assets/tari_banner.rs");
    let target_line_length = multiline_find_display_length(banner);
    for line in banner.lines() {
        println!("{}", line.to_string());
    }
    println!("\n{}", box_line(target_line_length, true));
    let logo = include!("../assets/tari_logo.rs");
    for line in logo.lines() {
        println!("{}", box_data(line.to_string(), target_line_length));
    }
    println!("{}", box_data(" ".to_string(), target_line_length));
    println!("{}", box_data("Tari Base Node".to_string(), target_line_length));
    println!("{}", box_data("~~~~~~~~~~~~~~".to_string(), target_line_length));
    println!(
        "{}",
        box_data(
            format!("Copyright 2019-{}. {}", Utc::now().year(), consts::APP_AUTHOR),
            target_line_length
        )
    );
    println!(
        "{}",
        box_data(format!("Version {}", consts::APP_VERSION), target_line_length)
    );
    println!("{}", box_separator(target_line_length));
    println!("{}", box_data("Commands".to_string(), target_line_length));
    println!("{}", box_data("~~~~~~~~".to_string(), target_line_length));
    println!("{}", box_separator(target_line_length));
    let rows = box_tabular_data_rows(command_data, row_cell_size, target_line_length, 10);
    for row in rows {
        println!("{}", row);
    }
    println!("{}", box_line(target_line_length, false));
}
pub fn print_banner ( commands : Vec < String > , chunk_size : i32 ) { let chunks : Vec < Vec < String > > = commands . chunks ( chunk_size as usize ) . map ( | x | x . to_vec ( ) ) . collect ( ) ; let mut cell_sizes = Vec :: new ( ) ; let mut row_cell_count : i32 = 0 ; let mut command_data : Vec < Vec < String > > = Vec :: new ( ) ; for chunk in chunks { let mut cells : Vec < String > = Vec :: new ( ) ; for item in chunk { cells . push ( item . clone ( ) ) ; cell_sizes . push ( item . chars ( ) . count ( ) ) ; row_cell_count += 1 ; } if row_cell_count < chunk_size { while row_cell_count < chunk_size { cells . push ( " " . to_string ( ) ) ; cell_sizes . push ( 1 ) ; row_cell_count += 1 ; } } else { row_cell_count = 0 ; } command_data . push ( cells ) ; } let row_cell_sizes : Vec < Vec < usize > > = cell_sizes . chunks ( chunk_size as usize ) . map ( | x | x . to_vec ( ) ) . collect ( ) ; let mut row_cell_size = Vec :: new ( ) ; let mut max_cell_size : usize = 0 ; for sizes in row_cell_sizes { for size in sizes { if size > max_cell_size { max_cell_size = size ; } } row_cell_size . push ( max_cell_size ) ; max_cell_size = 0 ; } let banner = include ! ( " " ) ; let target_line_length = multiline_find_display_length ( banner ) ; for line in banner . lines ( ) { println ! ( " " line to_string ( ) ) ; } println ! ( " \n " box_line ( target_line_length true ) ) ; let logo = include ! ( " " ) ; for line in logo . lines ( ) { println ! ( " " box_data ( line to_string ( ) target_line_length ) ) ; } println ! ( " " box_data ( " " to_string ( ) target_line_length ) ) ; println ! ( " " box_data ( " " to_string ( ) target_line_length ) ) ; println ! ( " " box_data ( " " to_string ( ) target_line_length ) ) ; println ! ( " " box_data ( format ( " " Utc now ( ) year ( ) consts APP_AUTHOR ) target_line_length ) ) ; println ! ( " " box_data ( format ( " " consts APP_VERSION ) target_line_length ) ) ; println ! ( " " box_separator ( target_line_length ) ) ; println ! ( " " box_data ( " " to_string ( ) target_line_length ) ) ; println ! ( " " box_data ( " " to_string ( ) target_line_length ) ) ; println ! ( " " box_separator ( target_line_length ) ) ; let rows = box_tabular_data_rows ( command_data , row_cell_size , target_line_length , 10 ) ; for row in rows { println ! ( " " row ) ; } println ! ( " " box_line ( target_line_length false ) ) ; }
Prints a pretty banner on the console as well as the list of available commands
Prints a pretty banner on the console as well as the list of available commands
commands
Vec<String>
chunk_size
i32
commands
Vec<String>
chunk_size
i32