X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Fosmclient.git;a=blobdiff_plain;f=osmclient%2Fcli_commands%2Fvim.py;fp=osmclient%2Fcli_commands%2Fvim.py;h=b2a073dc7cafd4e3effe490bf20d12f58c96b3b8;hp=ff1bcc639de0557883b75a7f1d9e2c9f6dcd9679;hb=9ba58bde6883dee6e6e6034232af0ff57772b70b;hpb=0046a316387d86e5df191b0aece617fcedeabb26 diff --git a/osmclient/cli_commands/vim.py b/osmclient/cli_commands/vim.py index ff1bcc6..b2a073d 100755 --- a/osmclient/cli_commands/vim.py +++ b/osmclient/cli_commands/vim.py @@ -14,6 +14,7 @@ # under the License. import click +from osmclient.common import print_output from osmclient.cli_commands import utils from prettytable import PrettyTable import yaml @@ -303,8 +304,15 @@ def vim_delete(ctx, name, force, wait): is_flag=True, help="get more details of the NS (project, vim, deployment status, configuration status.", ) +@click.option( + "-o", + default="table", + is_eager=True, + callback=print_output.validate_command_output, + help="get more details of the NS (project, vim, deployment status, configuration status.", +) @click.pass_context -def vim_list(ctx, filter, long): +def vim_list(ctx, filter, long, o): """list all VIM accounts""" logger.debug("") if filter: @@ -348,7 +356,8 @@ def vim_list(ctx, filter, long): [vim["name"], vim["uuid"], vim["_admin"].get("operationalState", "-")] ) table.align = "l" - print(table) + # print(table) + print_output.print_output(o, table.field_names, table._rows) @click.command(name="vim-show", short_help="shows the details of a VIM account") @@ -359,8 +368,15 @@ def vim_list(ctx, filter, long): help="restricts the information to the fields in the filter", ) @click.option("--literal", is_flag=True, help="print literally, no pretty table") +@click.option( + "-o", + default="table", + is_eager=True, + callback=print_output.validate_command_output, + help="adapt the output as table, yaml, csv, json, jsonpath", +) @click.pass_context -def vim_show(ctx, name, filter, literal): +def vim_show(ctx, name, filter, literal, o): """shows the details of a VIM account NAME: name or ID of the VIM account @@ -380,4 +396,5 @@ def vim_show(ctx, name, filter, literal): if not filter or k in filter: table.add_row([k, utils.wrap_text(text=json.dumps(v, indent=2), width=100)]) table.align = "l" - print(table) + # print(table) + print_output.print_output(o, table.field_names, table._rows)