summaryrefslogtreecommitdiff
path: root/docs/source/show_commands.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/source/show_commands.rst')
-rw-r--r--docs/source/show_commands.rst83
1 files changed, 68 insertions, 15 deletions
diff --git a/docs/source/show_commands.rst b/docs/source/show_commands.rst
index 5ad72de..0aa7d9f 100644
--- a/docs/source/show_commands.rst
+++ b/docs/source/show_commands.rst
@@ -27,26 +27,42 @@ 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.
-table
------
+html
+----
-The ``table`` formatter uses PrettyTable_ to produce output
-formatted for human consumption.
+The ``html`` formatter uses tablib_ to produce HTML output as a table.
-.. _PrettyTable: http://code.google.com/p/prettytable/
+::
+
+ (.venv)$ cliffdemo file -f html setup.py
+ <table>
+ <thead>
+ <tr><th>Field</th>
+ <th>Value</th></tr>
+ </thead>
+ <tr><td>Name</td>
+ <td>setup.py</td></tr>
+ <tr><td>Size</td>
+ <td>6373</td></tr>
+ <tr><td>UID</td>
+ <td>527</td></tr>
+ <tr><td>GID</td>
+ <td>501</td></tr>
+ <tr><td>Modified Time</td>
+ <td>1336353173.0</td></tr>
+ </table>
+
+json
+----
+
+The ``json`` formatter uses tablib_ to produce JSON output.
::
- (.venv)$ cliffdemo file setup.py
- +---------------+--------------+
- | Field | Value |
- +---------------+--------------+
- | Name | setup.py |
- | Size | 5825 |
- | UID | 502 |
- | GID | 20 |
- | Modified Time | 1335569964.0 |
- +---------------+--------------+
+ (.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}]
shell
-----
@@ -68,6 +84,41 @@ parsing overhead in shell scripts.
(.venv)$ echo $example_size
5916
+table
+-----
+
+The ``table`` formatter uses PrettyTable_ to produce output
+formatted for human consumption.
+
+.. _PrettyTable: http://code.google.com/p/prettytable/
+
+::
+
+ (.venv)$ cliffdemo file setup.py
+ +---------------+--------------+
+ | Field | Value |
+ +---------------+--------------+
+ | Name | setup.py |
+ | Size | 5825 |
+ | UID | 502 |
+ | GID | 20 |
+ | Modified Time | 1335569964.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}
Creating Your Own Formatter
---------------------------
@@ -77,3 +128,5 @@ another formatter with your program by subclassing from
:class:`cliff.formatters.base.ShowFormatter` and registering the
plugin in the ``cliff.formatter.show`` namespace.
+
+.. _tablib: https://github.com/kennethreitz/tablib