Skip to content

Commit

Permalink
Feature-#70: Implemented --no-reload flag
Browse files Browse the repository at this point in the history
  • Loading branch information
yushao2 committed May 4, 2021
1 parent acfcd74 commit 7a75b04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ async def main():


@main.command(help="Display a dashboard")
async def dashboard():
@click.option("-n", "--no-reload", is_flag=True)
async def dashboard(no_reload):
"""Dashboard command."""

click.echo("loading dashboard")
Expand All @@ -28,7 +29,7 @@ async def dashboard():
# TODO: move github polling to another thread
await asyncio.gather(
# asyncio.to_thread(update),
asyncio.to_thread(render),
asyncio.to_thread(render, no_reload=no_reload),
)


Expand Down
9 changes: 7 additions & 2 deletions reviews/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _render_pull_requests(
)


def render():
def render(no_reload: bool):
"""Renders Terminal UI Dashboard"""
(
job_progress,
Expand Down Expand Up @@ -80,7 +80,9 @@ def render():
log_component=generate_log_table(logs=logs),
)

with Live(layout_manager.layout, refresh_per_second=5, screen=True):
with Live(
layout_manager.layout, refresh_per_second=5, screen=not no_reload
) as live:
while True:
if not overall_progress or overall_progress.finished:
(
Expand All @@ -103,6 +105,9 @@ def render():
),
log_component=generate_log_table(logs=logs),
)
if no_reload:
live.stop()
break

if config.ENABLE_NOTIFICATIONS:
add_log_event(message="sending notification")
Expand Down

0 comments on commit 7a75b04

Please sign in to comment.