diff --git a/riocli/auth/util.py b/riocli/auth/util.py index 43f9c1c4..638e0d05 100644 --- a/riocli/auth/util.py +++ b/riocli/auth/util.py @@ -35,6 +35,8 @@ def select_project(config: Configuration, project: str = None) -> None: project_guid = project if project.startswith('project-') else find_project_guid(client, project) projects = client.list_projects() + # Sort projects based on their names for an easier selection + projects = sorted(projects, key=lambda p: p.name.lower()) project_map = dict() for project in projects: diff --git a/riocli/deployment/list.py b/riocli/deployment/list.py index 00cd3bde..b24e82a8 100644 --- a/riocli/deployment/list.py +++ b/riocli/deployment/list.py @@ -34,6 +34,7 @@ def list_deployments(device: str, phase: typing.List[str]) -> None: try: client = new_client() deployments = client.get_all_deployments(device_id=device, phases=phase) + deployments = sorted(deployments, key=lambda d: d.name.lower()) display_deployment_list(deployments, show_header=True) except Exception as e: click.secho(str(e), fg='red') diff --git a/riocli/device/list.py b/riocli/device/list.py index 968ecc15..fbdbf2b4 100644 --- a/riocli/device/list.py +++ b/riocli/device/list.py @@ -27,6 +27,7 @@ def list_devices() -> None: try: client = new_client() devices = client.get_all_devices() + devices = sorted(devices, key=lambda d: d.name.lower()) _display_device_list(devices, show_header=True) except Exception as e: click.secho(str(e), fg='red') diff --git a/riocli/disk/list.py b/riocli/disk/list.py index 03ec7daa..16acd391 100644 --- a/riocli/disk/list.py +++ b/riocli/disk/list.py @@ -26,6 +26,7 @@ def list_disks() -> None: """ try: disks = _api_call(HttpMethod.GET) + disks = sorted(disks, key=lambda d: d['name'].lower()) _display_disk_list(disks, show_header=True) except Exception as e: click.secho(str(e), fg='red') diff --git a/riocli/network/list.py b/riocli/network/list.py index 2e2c1fd7..eda7e833 100644 --- a/riocli/network/list.py +++ b/riocli/network/list.py @@ -37,6 +37,7 @@ def list_networks(network: str) -> None: if network in ['native', 'both']: networks += client.list_native_networks() + networks = sorted(networks, key=lambda n: n.name.lower()) _display_network_list(networks, show_header=True) except Exception as e: click.secho(str(e), fg='red') @@ -48,7 +49,7 @@ def _display_network_list( show_header: bool = True, ) -> None: if show_header: - click.secho('{:29} {:<15} {:8} {:8} {:20}'. + click.secho('{:29} {:<25} {:8} {:8} {:20}'. format('Network ID', 'Network Name', 'Runtime', 'Type', 'Phase'), fg='yellow') @@ -64,5 +65,5 @@ def _display_network_list( if phase and phase == DeploymentPhaseConstants.DEPLOYMENT_STOPPED.value: continue - click.secho('{:29} {:<15} {:8} {:8} {:20}'. + click.secho('{:29} {:<25} {:8} {:8} {:20}'. format(network.guid, network.name, network.runtime, network_type, phase)) diff --git a/riocli/package/list.py b/riocli/package/list.py index 2cc4b11d..ac600e20 100644 --- a/riocli/package/list.py +++ b/riocli/package/list.py @@ -64,5 +64,6 @@ def _display_package_list( description = description[:truncate_limit] + '..' if len(name) > truncate_limit: name = name[:truncate_limit] + '..' + click.echo('{:30} {:10} {:34} {:<48}'. format(name, package.packageVersion, package.packageId, description)) diff --git a/riocli/project/list.py b/riocli/project/list.py index c3680475..7c4081aa 100644 --- a/riocli/project/list.py +++ b/riocli/project/list.py @@ -28,6 +28,7 @@ def list_project(ctx: click.Context) -> None: try: client = new_client(with_project=False) projects = client.list_projects() + projects = sorted(projects, key=lambda p: p.name.lower()) current = ctx.obj.data.get('project_id', None) _display_project_list(projects, current, show_header=True) except Exception as e: @@ -45,5 +46,6 @@ def _display_project_list(projects: typing.List[Project], current: str = None, s fg = None if project.guid == current: fg = 'green' + click.secho('{:40} {:<25} {:<24} {:40}'.format(project.guid, project.name, project.created_at, project.creator), fg=fg) diff --git a/riocli/secret/list.py b/riocli/secret/list.py index f9209032..08ad5ddf 100644 --- a/riocli/secret/list.py +++ b/riocli/secret/list.py @@ -29,6 +29,7 @@ def list_secrets(secret_type: typing.Union[str, typing.Tuple[str]]) -> None: try: client = new_client() secrets = client.list_secrets() + secrets = sorted(secrets, key=lambda s: s.name.lower()) _display_secret_list(secrets, secret_type, show_header=True) except Exception as e: click.secho(str(e), fg='red')