========================
Show Output Formatters
========================
cliff is delivered with output formatters for show
commands. :class:`ShowOne` adds a command line switch to let the user
specify the formatter they want, so you don't have to do any extra
work in your application.
html
----
The ``html`` formatter uses tablib_ to produce HTML output as a table.
::
(.venv)$ cliffdemo file -f html setup.py
Field |
Value |
Name |
setup.py |
Size |
6373 |
UID |
527 |
GID |
501 |
Modified Time |
1336353173.0 |
json
----
The ``json`` formatter uses tablib_ to produce JSON output.
::
(.venv)$ cliffdemo file -f json setup.py
[{"Field": "Name", "Value": "setup.py"}, {"Field": "Size",
"Value": 6373}, {"Field": "UID", "Value": 527}, {"Field": "GID",
"Value": 501}, {"Field": "Modified Time", "Value": 1336353173.0}]
yaml
----
The ``yaml`` formatter uses tablib_ to produce YAML output as a
sequence of mappings.
::
(.venv)$ cliffdemo file -f yaml setup.py
- {Field: Name, Value: setup.py}
- {Field: Size, Value: 6373}
- {Field: UID, Value: 527}
- {Field: GID, Value: 501}
- {Field: Modified Time, Value: 1336353173.0}
.. _tablib: https://github.com/kennethreitz/tablib