From 3d4e5b5f07d25198bea588fb4ed411b4b01469c9 Mon Sep 17 00:00:00 2001 From: jfuller Date: Fri, 31 Mar 2023 11:50:04 +0200 Subject: [PATCH] GRIF-83 enhance product-components --- griffon/commands/entities.py | 4 +++- griffon/output.py | 40 ++++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/griffon/commands/entities.py b/griffon/commands/entities.py index 62a61b0..0332179 100644 --- a/griffon/commands/entities.py +++ b/griffon/commands/entities.py @@ -254,7 +254,9 @@ def list_components( session = CorgiService.create_session() conditions = default_conditions - conditions["include_fields"] = "link,purl,nvr,version,type,name,upstreams,related_url" + conditions[ + "include_fields" + ] = "link,purl,nvr,version,type,name,upstreams,related_url,download_url" # TODO- condition union could be a separate helper function diff --git a/griffon/output.py b/griffon/output.py index 9e01265..c0980cb 100644 --- a/griffon/output.py +++ b/griffon/output.py @@ -82,7 +82,7 @@ def component_type_style(type): def output_version(ctx, version): if version: if version.startswith("sha256") and ctx.obj["SHORT_VERSION_VALUES"]: - return f"sha256-..{version[-8:]}" + return f"sha256...{version[-8:]}" return version @@ -544,15 +544,37 @@ def text_output_list(ctx, output, format): else: component_ns = Text(purl.namespace.upper(), style="bold red") + version = output_version(ctx, purl.version) + if "version" in row: + version = row["version"] + if purl.version: + if purl.version.startswith("sha256"): + version = f"{row['version']} {output_version(ctx,purl.version)}" + + if "release" in row: + version = f"{version}-{row['release']}" if not ctx.obj["SHOW_PURL"]: - console.print( - component_ns, - purl.type.upper(), - Text(purl.name, style="bold white"), - output_version(ctx, purl.version), - row["related_url"], - purl.qualifiers.get("arch"), - ) + if ctx.obj["VERBOSE"] == 0: + console.print( + component_ns, + purl.type.upper(), + Text(purl.name, style="bold white"), + version, + row["related_url"], + purl.qualifiers.get("arch"), + ) + if ctx.obj["VERBOSE"] == 1: + component_name = purl.name + if "nvr" in row: + component_name = row["nvr"] + console.print( + component_ns, + purl.type.upper(), + Text(component_name, style="bold white"), + row["related_url"], + row["download_url"], + purl.qualifiers.get("arch"), + ) else: console.print( row["purl"],