recline.formatters.table_formatter module
Original © NetApp 2024
This module contains a table formatter for CLI output. The table formatter expects output to be an iterable of dictionary-like objects. For example, if a CLI command returned something like:
[{‘foo’: ‘bar’, ‘count’: 1}, {‘foo’: ‘baz’, ‘count’: 2}]
Then the table formatter would print this to the screen:
Foo |
Count |
bar baz |
1 2 |
- class recline.formatters.table_formatter.TableFormat
Bases:
OutputFormatter
A TableFormat object can be used as the return type for a CLI command. When specified, the returned value from the CLI command is assumed to be an interable of dictionary-like objects. All of the objects are assumed to be homogeneous with respsect to their keys. It will print out a table representing the data.
- format_output(results)
If there are no results given to us, print a message, otherwise print a table with a row for each record in the results.