1use {
2 crate::col::ALL_COLS,
3 termimad::{
4 MadSkin,
5 minimad::OwningTemplateExpander,
6 },
7 std::io::{
8 self,
9 Write,
10 },
11};
12
13static MD: &str = r#"
14The `--cols` launch argument lets you specify the columns of the **dysk** table.
15
16You can give the explicit list of all columns: `dysk -c dev+fs`
17
18You can add columns to the default ones: `dysk -c +dev+size`
19
20Complete syntax at https://dystroy.org/dysk/table
21
22|:-:|:-:|:-:|:-
23|column | aliases | default | content
24|:-:|:-:|:-:|-
25${column
26|${name}|${aliases}|${default}|${description}
27}
28|-
29"#;
30
31pub fn write<W: Write>(
33 w: &mut W,
34 color: bool,
35 ascii: bool,
36) -> io::Result<()> {
37 let mut expander = OwningTemplateExpander::new();
38 expander.set_default("");
39 for &col in ALL_COLS {
40 expander
41 .sub("column")
42 .set("name", col.name())
43 .set("aliases", col.aliases().join(", "))
44 .set("default", if col.is_default() { "x" } else { "" })
45 .set("description", col.description());
46 }
47 let mut skin = if color {
48 MadSkin::default()
49 } else {
50 MadSkin::no_style()
51 };
52 if ascii {
53 skin.limit_to_ascii();
54 }
55 skin.write_owning_expander_md(w, &expander, MD)
56}