From f1ed60f6576e16dc73ed836d24a1b32dbe9b4110 Mon Sep 17 00:00:00 2001 From: Alw3ys Date: Tue, 3 Oct 2023 10:43:08 -0700 Subject: [PATCH] feat: show secrets value --- deployplex/commands/env/list.py | 30 ++++++++---------------------- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/deployplex/commands/env/list.py b/deployplex/commands/env/list.py index 23aee11..9b39f3e 100644 --- a/deployplex/commands/env/list.py +++ b/deployplex/commands/env/list.py @@ -10,33 +10,19 @@ config = Config() -def display_table(headers, header_names, rows): - # Determine the maximum width of each column - column_widths = [len(header) for header in header_names] - for row in rows: - for i, header in enumerate(headers): - cell = row[header] - column_widths[i] = max(column_widths[i], len(str(cell))) - - # Print the table - formatted_headers = [header.ljust(width) for header, width in zip(header_names, column_widths)] - click.echo(' '.join(formatted_headers)) - for row in rows: - formatted_row = [str(row[header]).ljust(width) for header, width in zip(headers, column_widths)] - click.echo(' '.join(formatted_row)) - - @click.command() @click.option('--owner', default=None, required=True) -@click.option("--json", "json_output", is_flag=True, default=False) -def list(owner, json_output): +@click.option('--format', default=None, required=False, type=click.STRING) +def list(owner, format): """List environment variables""" auth_header = get_auth_header() params = owner_params(owner) result = requests.get(f"{config.api_base_url}/envs", headers=auth_header, params=params) - headers = ["name", "updated_at"] - header_names = ["NAME", "LAST UPDATE"] rows = result.json() - if json_output: + if format is None: + for row in rows: + click.echo(f'{row.get("name")}={row.get("value")}') + elif format == "json": return click.echo(json.dumps(rows)) - display_table(headers, header_names, rows) + else: + raise click.ClickException("Invalid format") diff --git a/pyproject.toml b/pyproject.toml index 461d411..b09ff27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "deployplex" -version = "0.0.4" +version = "0.0.5" description = "DeployPlex Command Line Interface (CLI)" authors = ["Alvaro Molina "] license = "Apache-2.0"