1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::execution::{PassFail, TaskResult};
use cli_table::{format::Justify, print_stdout, Cell, Style, Table};
use colored::Colorize;

pub fn display_execution_results(results: Vec<Vec<TaskResult>>) {
    let mut table = Vec::new();

    for (i, stage_results) in results.into_iter().enumerate() {
        for result in stage_results {
            table.push(vec![
                result.name.cell(),
                format!("{}", i + 1).cell().justify(Justify::Center),
                match result.result {
                    PassFail::Pass => result
                        .result
                        .to_string()
                        .green()
                        .cell()
                        .justify(Justify::Center),
                    PassFail::Fail => result
                        .result
                        .to_string()
                        .red()
                        .cell()
                        .justify(Justify::Center),
                },
                result.elapsed_time.cell().justify(Justify::Center),
                result.file_path.cell().justify(Justify::Right),
            ])
        }
    }

    assert!(print_stdout(
        table
            .table()
            .title(vec![
                "Task".yellow().cell().bold(true),
                "Stage".yellow().cell().bold(true),
                "Result".yellow().cell().bold(true),
                "Run Time(s)".yellow().cell().bold(true),
                "File".yellow().cell().bold(true),
            ])
            .bold(true),
    )
    .is_ok());
}