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
47
48
49
50[<AutoOpen>]
module Duets.Cli.Components.Table
open Duets.Cli.Text
open Spectre.Console
let private createTable
title
(columns: string list)
(rows: (string list) list)
=
let mutable table = Table()
match title with
| Some title -> table.Title <- TableTitle(Styles.title title)
| None -> ()
columns |> List.iter (fun column -> table <- table.AddColumn(column))
rows |> List.iter (fun row -> table <- row |> Array.ofList |> table.AddRow)
table
/// <summary>
/// Shows a table with the given columns and rows.
/// </summary>
/// <param name="columns">
/// Column text to be shown. Each field in the list correspond with each column
/// </param>
/// <param name="rows">
/// Row text to be shown. Each field in the list correspond with each column
/// </param>
let showTable columns rows =
createTable None columns rows |> AnsiConsole.Write
/// <summary>
/// Shows a table with the given title, columns and rows.
/// </summary>
/// <param name="title">
/// Title of the table.
/// </param>
/// <param name="columns">
/// Column text to be shown. Each field in the list correspond with each column
/// </param>
/// <param name="rows">
/// Row text to be shown. Each field in the list correspond with each column
/// </param>
let showTableWithTitle title columns rows =
createTable (Some title) columns rows |> AnsiConsole.Write