Skip to content

Commit 77f94df

Browse files
feat: loading state
1 parent 03c417e commit 77f94df

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/commands/daily.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ def daily(
2525
result = get_daily_question()
2626
question = result['data']['activeDailyCodingChallengeQuestion']
2727
typer.echo("\r" + " " * 30 + "\r", nl=False)
28+
29+
show(problem=question['question']['titleSlug'], save=save)
2830
except Exception as e:
2931
typer.echo("\n" + typer.style(f"❌ Failed to fetch daily question: {str(e)}", fg=typer.colors.RED))
3032
raise typer.Exit(1)
3133

32-
show(problem=question['question']['titleSlug'], save=save)
3334

3435
if not no_editor and editor:
3536
try:

src/commands/list_problems.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Optional
55
from ..lib.ui import display_problem_list
66
from ..server.auth import Auth
7+
from rich.progress import Progress, SpinnerColumn, TextColumn
78

89
import typer
910

@@ -31,8 +32,12 @@ def list_problems(
3132

3233
tags = tag.split(',') if tag else []
3334

34-
with Live(Spinner('dots'), refresh_per_second=10) as live:
35-
live.console.print("[cyan]Fetching problems...")
35+
with Progress(
36+
SpinnerColumn(),
37+
TextColumn("[progress.description]{task.description}"),
38+
transient=True,
39+
) as progress:
40+
progress.add_task("Fetching problems...", total=1)
3641

3742
session = AuthManager.session_manager.load_session()
3843
if not session:

src/commands/show.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from ..lib.problem_ui import ProblemDetails
44
from ..server.auth import Auth
55
from ..server.solution_manager import SolutionManager
6+
from rich.progress import Progress, SpinnerColumn, TextColumn
67

78
auth_manager = Auth()
89
solution_manager = SolutionManager(auth_manager.get_session())
@@ -24,7 +25,14 @@ def show(
2425
raise typer.Exit(1)
2526

2627
try:
27-
data = solution_manager.get_question_data(problem)
28+
with Progress(
29+
SpinnerColumn(),
30+
TextColumn("[progress.description]{task.description}"),
31+
transient=True
32+
) as progress:
33+
progress.add_task("Fetching problem data...", total=1)
34+
data = solution_manager.get_question_data(problem)
35+
2836
if not data.get('data', {}).get('question'):
2937
typer.echo(typer.style(f"❌ Problem '{problem}' not found", fg=typer.colors.RED))
3038
raise typer.Exit(1)

0 commit comments

Comments
 (0)