File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33todo-app script entrypoint
44"""
55
6- import argparse
76import os
87import subprocess
98import sys
109
11- from todo_app import __version__ , config
10+ from todo_app import config
1211
1312
1413def main ():
1514 """Main entry point for the application."""
16- parser = argparse .ArgumentParser (
17- prog = "todo_app" ,
18- description = "An application for managing TODOs" ,
19- )
20- parser .add_argument ("--version" , action = "version" , version = __version__ )
15+ parser = config .create_arg_parser ()
16+ parser .prog = "todo_app"
17+ parser .description = "An application for managing TODOs"
2118 parser .add_argument (
2219 "--dev" ,
2320 action = "store_true" ,
2421 help = "Run Flask development server instead of gunicorn" ,
2522 )
2623 args = parser .parse_args ()
2724
28- log = config .setup_logging ()
25+ log = config .setup_logging (vars ( args ) )
2926 log .debug ("Logging initialized with level: %s" , log .level )
3027
3128 port = int (os .environ .get ("PORT" , "8000" ))
Original file line number Diff line number Diff line change @@ -40,16 +40,18 @@ def create_arg_parser() -> ArgumentParser:
4040 return parser
4141
4242
43- def get_args_config () -> dict :
43+ def get_args_config (args : dict | None = None ) -> dict :
4444 """Turn parse arguments into a config"""
45+ if args is not None :
46+ return args
4547 parser = create_arg_parser ()
4648 return vars (parser .parse_args ())
4749
4850
49- def setup_logging () -> logging .Logger :
51+ def setup_logging (args : dict | None = None ) -> logging .Logger :
5052 """Setup logging"""
5153 logging .basicConfig (level = "WARNING" , format = constants .LOG_FORMAT )
5254 log = logging .getLogger (__project_name__ )
53- configuration = get_args_config ()
55+ configuration = get_args_config (args )
5456 logging .getLogger ().setLevel (configuration ["loglevel" ])
5557 return log
You can’t perform that action at this time.
0 commit comments