Skip to content

Commit

Permalink
feat: show secrets value
Browse files Browse the repository at this point in the history
  • Loading branch information
Alw3ys committed Oct 3, 2023
1 parent ea53d10 commit f1ed60f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
30 changes: 8 additions & 22 deletions deployplex/commands/env/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <alw3ys@gmail.com>"]
license = "Apache-2.0"
Expand Down

0 comments on commit f1ed60f

Please sign in to comment.