@@ -21,14 +21,22 @@ def cli():
21
21
def list ():
22
22
"""List all available tasks."""
23
23
tasks_dir = os .path .join (os .path .dirname (__file__ ), "tasks" )
24
- click . echo ( "Available tasks:" )
25
- for filename in os .listdir (tasks_dir ):
24
+
25
+ for filename in sorted ( os .listdir (tasks_dir ) ):
26
26
if filename .endswith (".py" ) and not filename .startswith ("_" ):
27
27
module_name = filename [:- 3 ]
28
28
module = importlib .import_module (f"tasks.{ module_name } " )
29
- description = module .__doc__ or "No description"
30
- description = description .strip ().split ("\n " )[0 ]
31
- click .echo (f"- { module_name } : { description } " )
29
+
30
+ doc = module .__doc__ or "No description"
31
+ doc_lines = doc .strip ().split ("\n " )
32
+ while doc_lines and not doc_lines [0 ].strip ():
33
+ doc_lines .pop (0 )
34
+ while doc_lines and not doc_lines [- 1 ].strip ():
35
+ doc_lines .pop ()
36
+
37
+ click .echo (f"\n { module_name } :" )
38
+ for line in doc_lines :
39
+ click .echo (f" { line } " )
32
40
33
41
34
42
@cli .command ()
@@ -38,27 +46,29 @@ def list():
38
46
type = click .Choice (["all" , "last" , "custom" ]),
39
47
default = "all" ,
40
48
help = "Type of refresh to perform" ,
49
+ hidden = True ,
41
50
)
42
51
@click .option (
43
52
"--custom-years" ,
44
53
type = str ,
45
54
help = "Comma-separated list of years to process (for custom refresh type)" ,
55
+ hidden = True ,
46
56
)
47
- def run (task_name , refresh_type , custom_years ):
57
+ def run (task_name , refresh_type , custom_years , drop_tables ):
48
58
"""Run a specified task."""
49
59
try :
50
60
module = importlib .import_module (f"tasks.{ task_name } " )
51
61
task_func = getattr (module , "execute" )
52
62
logging .info (f"Starting task { task_name } ..." )
53
-
63
+
54
64
# Parse custom years if provided
55
65
custom_years_list = None
56
66
if custom_years :
57
67
custom_years_list = [year .strip () for year in custom_years .split ("," )]
58
-
68
+
59
69
# Call the task function with parameters
60
70
task_func (refresh_type = refresh_type , custom_years = custom_years_list )
61
-
71
+
62
72
logging .info (f"Task { task_name } completed." )
63
73
except (ModuleNotFoundError , AttributeError ):
64
74
logging .error (f"Task { task_name } not found." )
0 commit comments