File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change 99app = typer .Typer (no_args_is_help = True )
1010
1111
12+ def echo (text , fg = typer .colors .GREEN ):
13+ typer .echo (
14+ typer .style (
15+ text ,
16+ fg = fg ,
17+ )
18+ )
19+
20+
1221def import_challenge_module (day : int ):
22+ module_name = f"aoc.day_{ day :02} "
1323 try :
14- module = importlib .import_module (f"aoc.day_ { day :02 } " )
24+ module = importlib .import_module (module_name )
1525 except ModuleNotFoundError as e :
16- typer .echo (
17- typer .style (
18- f'You have not solved day { day } yet. Start it using "new-day" command' ,
26+ echo (
27+ f'Could not import "{ e .name } "' ,
28+ fg = typer .colors .RED ,
29+ )
30+ if e .name == module_name :
31+ echo (
32+ f"You have not solved day { day } yet. Start it using 'new-day' command" ,
1933 fg = typer .colors .RED ,
2034 )
21- )
35+ else :
36+ raise e
2237 raise typer .Exit (1 ) from e
2338 return module
2439
You can’t perform that action at this time.
0 commit comments