Skip to content

Commit

Permalink
Colors for run status
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreLobato committed Jan 17, 2025
1 parent c85defa commit 503c590
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/oceanum/cli/prax/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def validate_project(ctx: click.Context, specfile: click.Path):
def deploy_project(
ctx: click.Context,
specfile: click.Path,
name: str|None,
name: str|None,
org: str|None,
user: str|None,
wait: bool,
Expand Down
15 changes: 15 additions & 0 deletions src/oceanum/cli/prax/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@

from .models import ErrorResponse, ProjectSpec, SecretData

def format_run_status(status: str) -> str:
status = status.lower()
if status == 'pending':
return click.style(status.upper(), fg='white')
elif status == 'running':
return click.style(status.upper(), fg='cyan')
elif status == 'succeeded':
return click.style(status.upper(), fg='green')
elif status == 'failed':
return click.style(status.upper(), fg='red')
elif status == 'error':
return click.style(status.upper(), fg='red')
else:
return status

def format_route_status(status: str) -> str:
if status == 'online':
return click.style(status.upper(), fg='green')
Expand Down
10 changes: 7 additions & 3 deletions src/oceanum/cli/prax/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
project_name_option,
name_argument
)
from .utils import echoerr
from .utils import echoerr, format_run_status as frs

def parse_parameters(parameters: list[str]|None) -> dict|None:
params = {}
Expand All @@ -36,7 +36,7 @@ def parse_parameters(parameters: list[str]|None) -> dict|None:
RenderField(
label='Last Run',
path='$.last_run',
mod=lambda x: x['status'] if x is not None else 'N/A'
mod=lambda x: frs(x['status']) if x is not None else 'N/A'
),
RenderField(
label='Started at',
Expand Down Expand Up @@ -267,6 +267,10 @@ def retry_task(ctx: click.Context, name: str, **filters):
@output_format_option
@login_required
def list_builds(ctx: click.Context, output: str, **filters):
build_fields = LIST_FIELDS + [
RenderField(label='Source Branch/Tag', path='$.source_ref'),
]
build_fields.pop(-2)
client = PRAXClient(ctx)
builds = client.list_builds(**{
k: v for k, v in filters.items() if v is not None
Expand All @@ -278,7 +282,7 @@ def list_builds(ctx: click.Context, output: str, **filters):
echoerr(builds)
sys.exit(1)
else:
click.echo(Renderer(data=builds, fields=LIST_FIELDS).render(output_format=output))
click.echo(Renderer(data=builds, fields=build_fields).render(output_format=output))


@describe.command(name='build', help='Describe PRAX Build')
Expand Down

0 comments on commit 503c590

Please sign in to comment.