|
9 | 9 | from shutil import get_terminal_size |
10 | 10 | from textwrap import TextWrapper, indent |
11 | 11 |
|
| 12 | +from rich import box |
12 | 13 | from rich.columns import Columns |
13 | 14 | from rich.console import Console |
| 15 | +from rich.table import Table |
14 | 16 |
|
15 | 17 | from . import __version__, phyvars |
16 | 18 | from ._helpers import baredoc, walk |
@@ -161,22 +163,28 @@ def config_pp(subs: Iterable[str], conf: Config) -> None: |
161 | 163 | subs: conf sections to print. |
162 | 164 | conf: configuration. |
163 | 165 | """ |
164 | | - print("(c|f): available only as CLI argument/in the config file", end="\n\n") |
| 166 | + console = Console() |
165 | 167 | for sub in subs: |
| 168 | + table = Table(title=sub, box=box.SIMPLE) |
| 169 | + table.add_column(header="option", no_wrap=True) |
| 170 | + table.add_column(header="doc") |
| 171 | + table.add_column(header="cli", no_wrap=True) |
| 172 | + table.add_column(header="file", no_wrap=True) |
| 173 | + |
166 | 174 | section: Section = getattr(conf, sub) |
167 | | - hlp_lst = [] |
168 | 175 | for fld in fields(section): |
169 | 176 | opt = fld.name |
170 | 177 | entry = section.meta_(opt).entry |
171 | | - if entry.in_cli ^ entry.in_file: |
172 | | - opt += " (c)" if entry.in_cli else " (f)" |
173 | | - hlp_lst.append((opt, entry.doc)) |
174 | | - if hlp_lst: |
175 | | - print(f"{sub}:") |
176 | | - _pretty_print( |
177 | | - hlp_lst, sep=" -- ", text_width=min(get_terminal_size().columns, 100) |
| 178 | + table.add_row( |
| 179 | + opt, |
| 180 | + entry.doc, |
| 181 | + "yes" if entry.in_cli else "no", |
| 182 | + "yes" if entry.in_file else "no", |
178 | 183 | ) |
179 | | - print() |
| 184 | + |
| 185 | + if table.rows: |
| 186 | + console.print(table) |
| 187 | + console.print() |
180 | 188 |
|
181 | 189 |
|
182 | 190 | def config_cmd(conf: Config) -> None: |
|
0 commit comments