Use "--format" instead of "--json" when showing a container
Bug #1657959 Change-Id: Iaba8cd1cbe76f22960beb83fc6103dca71da5599
This commit is contained in:
parent
0ec418dbe6
commit
a8661e2366
@ -122,7 +122,7 @@ class ShellTest(utils.TestCase):
|
|||||||
stdout, stderr = self.shell('bash-completion')
|
stdout, stderr = self.shell('bash-completion')
|
||||||
# just check we have some output
|
# just check we have some output
|
||||||
required = [
|
required = [
|
||||||
'.*--json',
|
'.*--format',
|
||||||
'.*help',
|
'.*help',
|
||||||
'.*show',
|
'.*show',
|
||||||
'.*--name']
|
'.*--name']
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
import yaml
|
||||||
|
|
||||||
from zunclient.common import cliutils as utils
|
from zunclient.common import cliutils as utils
|
||||||
from zunclient.common import utils as zun_utils
|
from zunclient.common import utils as zun_utils
|
||||||
@ -191,16 +192,22 @@ def do_delete(cs, args):
|
|||||||
@utils.arg('container',
|
@utils.arg('container',
|
||||||
metavar='<container>',
|
metavar='<container>',
|
||||||
help='ID or name of the container to show.')
|
help='ID or name of the container to show.')
|
||||||
@utils.arg('--json',
|
@utils.arg('-f', '--format',
|
||||||
action='store_true',
|
metavar='<format>',
|
||||||
default=False,
|
action='store',
|
||||||
help='Print JSON representation of the container.')
|
choices=['json', 'yaml', 'table'],
|
||||||
|
default='table',
|
||||||
|
help='Print representation of the container.'
|
||||||
|
'The choices of the output format is json,table,yaml.'
|
||||||
|
'Defaults to table.')
|
||||||
def do_show(cs, args):
|
def do_show(cs, args):
|
||||||
"""Show details of a container."""
|
"""Show details of a container."""
|
||||||
container = cs.containers.get(args.container)
|
container = cs.containers.get(args.container)
|
||||||
if args.json:
|
if args.format == 'json':
|
||||||
print(json.dumps(container._info))
|
print(json.dumps(container._info, indent=4, sort_keys=True))
|
||||||
else:
|
elif args.format == 'yaml':
|
||||||
|
print(yaml.safe_dump(container._info, default_flow_style=False))
|
||||||
|
elif args.format == 'table':
|
||||||
_show_container(container)
|
_show_container(container)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user