88from codeflash .cli_cmds .cmd_init import init_codeflash , install_github_actions
99from codeflash .cli_cmds .console import logger
1010from codeflash .code_utils import env_utils
11+ from codeflash .code_utils .code_utils import exit_with_message
1112from codeflash .code_utils .config_parser import parse_config_file
1213from codeflash .version import __version__ as version
1314
@@ -42,7 +43,7 @@ def parse_args() -> Namespace:
4243 )
4344 parser .add_argument ("--test-framework" , choices = ["pytest" , "unittest" ], default = "pytest" )
4445 parser .add_argument ("--config-file" , type = str , help = "Path to the pyproject.toml with codeflash configs." )
45- parser .add_argument ("--replay-test" , type = str , help = "Path to replay test to optimize functions from" )
46+ parser .add_argument ("--replay-test" , type = str , nargs = "+" , help = "Paths to replay test to optimize functions from" )
4647 parser .add_argument (
4748 "--no-pr" , action = "store_true" , help = "Do not create a PR for the optimization, only update the code locally."
4849 )
@@ -83,25 +84,22 @@ def process_and_validate_cmd_args(args: Namespace) -> Namespace:
8384 sys .exit ()
8485 if not check_running_in_git_repo (module_root = args .module_root ):
8586 if not confirm_proceeding_with_no_git_repo ():
86- logger .critical ("No git repository detected and user aborted run. Exiting..." )
87- sys .exit (1 )
87+ exit_with_message ("No git repository detected and user aborted run. Exiting..." , error_on_exit = True )
8888 args .no_pr = True
8989 if args .function and not args .file :
90- logger .error ("If you specify a --function, you must specify the --file it is in" )
91- sys .exit (1 )
90+ exit_with_message ("If you specify a --function, you must specify the --file it is in" , error_on_exit = True )
9291 if args .file :
9392 if not Path (args .file ).exists ():
94- logger .error (f"File { args .file } does not exist" )
95- sys .exit (1 )
93+ exit_with_message (f"File { args .file } does not exist" , error_on_exit = True )
9694 args .file = Path (args .file ).resolve ()
9795 if not args .no_pr :
9896 owner , repo = get_repo_owner_and_name ()
9997 require_github_app_or_exit (owner , repo )
10098 if args .replay_test :
101- if not Path ( args .replay_test ). is_file () :
102- logger . error ( f"Replay test file { args . replay_test } does not exist" )
103- sys . exit ( 1 )
104- args .replay_test = Path (args . replay_test ).resolve ()
99+ for test_path in args .replay_test :
100+ if not Path ( test_path ). is_file ():
101+ exit_with_message ( f"Replay test file { test_path } does not exist" , error_on_exit = True )
102+ args .replay_test = [ Path (replay_test ).resolve () for replay_test in args . replay_test ]
105103
106104 return args
107105
@@ -110,8 +108,7 @@ def process_pyproject_config(args: Namespace) -> Namespace:
110108 try :
111109 pyproject_config , pyproject_file_path = parse_config_file (args .config_file )
112110 except ValueError as e :
113- logger .error (e )
114- sys .exit (1 )
111+ exit_with_message (f"Error parsing config file: { e } " , error_on_exit = True )
115112 supported_keys = [
116113 "module_root" ,
117114 "tests_root" ,
@@ -203,8 +200,7 @@ def handle_optimize_all_arg_parsing(args: Namespace) -> Namespace:
203200 )
204201 apologize_and_exit ()
205202 if not args .no_pr and not check_and_push_branch (git_repo ):
206- logger .critical ("❌ Branch is not pushed. Exiting..." )
207- sys .exit (1 )
203+ exit_with_message ("Branch is not pushed..." , error_on_exit = True )
208204 owner , repo = get_repo_owner_and_name (git_repo )
209205 if not args .no_pr :
210206 require_github_app_or_exit (owner , repo )
0 commit comments