diff options
author | Doug Hellmann <doug.hellmann@gmail.com> | 2012-08-02 10:05:36 -0700 |
---|---|---|
committer | Doug Hellmann <doug.hellmann@gmail.com> | 2012-08-02 10:05:36 -0700 |
commit | 22d32f60d3481b89a366fcf3416992618cb5a9e3 (patch) | |
tree | 1dce3d965f14f8b9dc27e5ba9b56e2b084014638 /docs/source/show_commands.rst | |
parent | ce0aa4609c76e60ea580afcfee1f8103931b0fee (diff) | |
parent | 8896e385ebc963145677303bf8d6eb134dcf582c (diff) | |
download | cliff-tablib-22d32f60d3481b89a366fcf3416992618cb5a9e3.tar.gz |
Merge pull request #1 from dhellmann/feature/package-tablib-support1.0
Start cliff-tablib repo
Diffstat (limited to 'docs/source/show_commands.rst')
-rw-r--r-- | docs/source/show_commands.rst | 76 |
1 files changed, 3 insertions, 73 deletions
diff --git a/docs/source/show_commands.rst b/docs/source/show_commands.rst index e848960..661acec 100644 --- a/docs/source/show_commands.rst +++ b/docs/source/show_commands.rst @@ -1,27 +1,6 @@ -=============== - Show Commands -=============== - -One of the most common patterns with command line programs is the need -to print properties of objects. cliff provides a base class for -commands of this type so that they only need to prepare the data, and -the user can choose from one of several output formatter plugins to -see the data in their preferred format. - -ShowOne -======= - -The :class:`cliff.show.ShowOne` base class API extends -:class:`Command` to allow :func:`take_action` to return data to be -formatted using a user-selectable formatter. Subclasses should provide -a :func:`take_action` implementation that returns a two member tuple -containing a tuple with the names of the columns in the dataset and an -iterable that contains the data values associated with those -names. See the description of :ref:`the file command in the demoapp -<demoapp-show>` for details. - -Show Output Formatters -====================== +======================== + Show Output Formatters +======================== cliff is delivered with output formatters for show commands. :class:`ShowOne` adds a command line switch to let the user @@ -65,47 +44,6 @@ The ``json`` formatter uses tablib_ to produce JSON output. "Value": 6373}, {"Field": "UID", "Value": 527}, {"Field": "GID", "Value": 501}, {"Field": "Modified Time", "Value": 1336353173.0}] -shell ------ - -The ``shell`` formatter produces output that can be parsed directly by -a typical UNIX shell as variable assignments. This avoids extra -parsing overhead in shell scripts. - -:: - - (.venv)$ cliffdemo file -f shell setup.py - name="setup.py" - size="5916" - uid="527" - gid="501" - modified_time="1335655655.0" - - (.venv)$ eval "$(cliffdemo file -f shell --prefix example_ setup.py)" - (.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 ---- @@ -121,13 +59,5 @@ sequence of mappings. - {Field: GID, Value: 501} - {Field: Modified Time, Value: 1336353173.0} -Creating Your Own Formatter ---------------------------- - -If the standard formatters do not meet your needs, you can bundle -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 |