diff options
author | TerryHowe <terrylhowe@gmail.com> | 2015-05-13 13:07:16 -0600 |
---|---|---|
committer | TerryHowe <terrylhowe@gmail.com> | 2015-05-26 10:18:21 -0600 |
commit | 24120da1df54b1438fa173430fd9b0270995b00f (patch) | |
tree | fafd859e101e2e7f5030811d84ac04c2f45e8e8d /cliff/formatters | |
parent | 4abf524be5be719ba0b2e6846bb67828ee7653a5 (diff) | |
download | cliff-24120da1df54b1438fa173430fd9b0270995b00f.tar.gz |
Add value format for list command
The value format for the show command is very handy for shell
scripting and a value format for the list command would be just
as handy. It will allow command substitution and piping like:
os container list --format value | grep tmp | while read NAME
do
os container delete $NAME
done
Change-Id: If9784c27d689073e9145b2cb8077ac604025a4c3
Diffstat (limited to 'cliff/formatters')
-rw-r--r-- | cliff/formatters/value.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cliff/formatters/value.py b/cliff/formatters/value.py index 9910319..6cc6744 100644 --- a/cliff/formatters/value.py +++ b/cliff/formatters/value.py @@ -1,14 +1,22 @@ """Output formatters values only """ +import six + +from .base import ListFormatter from .base import SingleFormatter -class ValueFormatter(SingleFormatter): +class ValueFormatter(ListFormatter, SingleFormatter): def add_argument_group(self, parser): pass + def emit_list(self, column_names, data, stdout, parsed_args): + for row in data: + stdout.write(' '.join(map(six.text_type, row)) + u'\n') + return + def emit_one(self, column_names, data, stdout, parsed_args): for value in data: stdout.write('%s\n' % str(value)) |