Skip to content

Commit 7c44cc8

Browse files
refactor: restructure main function to support dynamic function calls via command line arguments
1 parent 3897c04 commit 7c44cc8

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/main.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import sys
23

34
logging.basicConfig(
45
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
@@ -29,9 +30,30 @@ def github_collect_repo():
2930
def hellogithub_collect_repo():
3031
from controllers.hellogithub_ctl import HelloGitHubController
3132

33+
3234
ctl = HelloGitHubController()
3335
ctl.collect_repo(max_pages=1000)
3436

3537

3638
if __name__ == "__main__":
37-
hellogithub_collect_repo()
39+
40+
funcs = {
41+
"hellogithub_collect_repo": hellogithub_collect_repo,
42+
"gitstar_collect_repo": gitstar_collect_repo,
43+
"gitstar_collect_user": gitstar_collect_user,
44+
"github_collect_repo": github_collect_repo,
45+
}
46+
47+
if len(sys.argv) < 2:
48+
print("Usage: python main.py <function_name>")
49+
print("Available functions:", ", ".join(funcs.keys()))
50+
sys.exit(1)
51+
52+
func_name = sys.argv[1]
53+
func = funcs.get(func_name)
54+
if func is None:
55+
print(f"Unknown function: {func_name}")
56+
print("Available functions:", ", ".join(funcs.keys()))
57+
sys.exit(1)
58+
59+
func()

0 commit comments

Comments
 (0)