Allow raw listing of cluster names in CLI
This commit is contained in:
parent
80fe96b24d
commit
3f5b7045a2
|
@ -251,7 +251,11 @@ def cluster_remove(name):
|
||||||
# pvc cluster list
|
# pvc cluster list
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@click.command(name='list', short_help='List all available clusters.')
|
@click.command(name='list', short_help='List all available clusters.')
|
||||||
def cluster_list():
|
@click.option(
|
||||||
|
'-r', '--raw', 'raw', is_flag=True, default=False,
|
||||||
|
help='Display the raw list of cluster names only.'
|
||||||
|
)
|
||||||
|
def cluster_list(raw):
|
||||||
"""
|
"""
|
||||||
List all the available PVC clusters configured in this CLI instance.
|
List all the available PVC clusters configured in this CLI instance.
|
||||||
"""
|
"""
|
||||||
|
@ -302,27 +306,28 @@ def cluster_list():
|
||||||
if _api_key_length > api_key_length:
|
if _api_key_length > api_key_length:
|
||||||
api_key_length = _api_key_length
|
api_key_length = _api_key_length
|
||||||
|
|
||||||
# Display the data nicely
|
if not raw:
|
||||||
click.echo("Available clusters:")
|
# Display the data nicely
|
||||||
click.echo()
|
click.echo("Available clusters:")
|
||||||
click.echo(
|
click.echo()
|
||||||
'{bold}{name: <{name_length}} {description: <{description_length}} {address: <{address_length}} {port: <{port_length}} {scheme: <{scheme_length}} {api_key: <{api_key_length}}{end_bold}'.format(
|
click.echo(
|
||||||
bold=ansiprint.bold(),
|
'{bold}{name: <{name_length}} {description: <{description_length}} {address: <{address_length}} {port: <{port_length}} {scheme: <{scheme_length}} {api_key: <{api_key_length}}{end_bold}'.format(
|
||||||
end_bold=ansiprint.end(),
|
bold=ansiprint.bold(),
|
||||||
name="Name",
|
end_bold=ansiprint.end(),
|
||||||
name_length=name_length,
|
name="Name",
|
||||||
description="Description",
|
name_length=name_length,
|
||||||
description_length=description_length,
|
description="Description",
|
||||||
address="Address",
|
description_length=description_length,
|
||||||
address_length=address_length,
|
address="Address",
|
||||||
port="Port",
|
address_length=address_length,
|
||||||
port_length=port_length,
|
port="Port",
|
||||||
scheme="Scheme",
|
port_length=port_length,
|
||||||
scheme_length=scheme_length,
|
scheme="Scheme",
|
||||||
api_key="API Key",
|
scheme_length=scheme_length,
|
||||||
api_key_length=api_key_length
|
api_key="API Key",
|
||||||
|
api_key_length=api_key_length
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
for cluster in clusters:
|
for cluster in clusters:
|
||||||
cluster_details = clusters[cluster]
|
cluster_details = clusters[cluster]
|
||||||
|
@ -341,24 +346,27 @@ def cluster_list():
|
||||||
if not api_key:
|
if not api_key:
|
||||||
api_key = 'N/A'
|
api_key = 'N/A'
|
||||||
|
|
||||||
click.echo(
|
if not raw:
|
||||||
'{bold}{name: <{name_length}} {description: <{description_length}} {address: <{address_length}} {port: <{port_length}} {scheme: <{scheme_length}} {api_key: <{api_key_length}}{end_bold}'.format(
|
click.echo(
|
||||||
bold='',
|
'{bold}{name: <{name_length}} {description: <{description_length}} {address: <{address_length}} {port: <{port_length}} {scheme: <{scheme_length}} {api_key: <{api_key_length}}{end_bold}'.format(
|
||||||
end_bold='',
|
bold='',
|
||||||
name=cluster,
|
end_bold='',
|
||||||
name_length=name_length,
|
name=cluster,
|
||||||
description=description,
|
name_length=name_length,
|
||||||
description_length=description_length,
|
description=description,
|
||||||
address=address,
|
description_length=description_length,
|
||||||
address_length=address_length,
|
address=address,
|
||||||
port=port,
|
address_length=address_length,
|
||||||
port_length=port_length,
|
port=port,
|
||||||
scheme=scheme,
|
port_length=port_length,
|
||||||
scheme_length=scheme_length,
|
scheme=scheme,
|
||||||
api_key=api_key,
|
scheme_length=scheme_length,
|
||||||
api_key_length=api_key_length
|
api_key=api_key,
|
||||||
|
api_key_length=api_key_length
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
else:
|
||||||
|
click.echo(cluster)
|
||||||
|
|
||||||
|
|
||||||
# Validate that the cluster is set for a given command
|
# Validate that the cluster is set for a given command
|
||||||
|
|
Loading…
Reference in New Issue