by shigemk2

当面は技術的なことしか書かない

cli_helpers

>>> from cli_helpers import tabular_output
>>> data = [[1, 'Asgard', True], [2, 'Camelot', False], [3, 'El Dorado', True]]
>>> headers = ['id', 'city', 'visited']
>>> [print(test) for test in tabular_output.format_output(data, headers, format_name='simple')]
id  city       visited
--  ---------  -------
 1  Asgard     True
 2  Camelot    False
 3  El Dorado  True
[None, None, None, None, None]
>>> data = [[1, 'Asgard\nTest', True], [2, 'Camelot', False], [3, 'El Dorado', True]]
>>> [print(test) for test in tabular_output.format_output(data, headers, format_name='simple')]
id  city       visited
--  ---------  -------
 1  Asgard     True
    Test
 2  Camelot    False
 3  El Dorado  True
[None, None, None, None, None, None]
>>> [print(test) for test in tabular_output.format_output(data, headers, format_name='ascii')]
+----+--------------+---------+
| id | city         | visited |
+----+--------------+---------+
| 1  | Asgard\nTest | True    |
| 2  | Camelot      | False   |
| 3  | El Dorado    | True    |
+----+--------------+---------+
[None, None, None, None, None, None, None]
>>> [print(test) for test in tabular_output.format_output(data, headers, format_name='github')]
| id | city         | visited |
|----|--------------|---------|
|  1 | Asgard\nTest | True    |
|  2 | Camelot      | False   |
|  3 | El Dorado    | True    |
[None, None, None, None, None]

Quickstart — CLI Helpers 2.1.0 documentation