@@ -46,13 +46,21 @@ def main() -> None:
4646 config .base_dir = os .path .abspath (config .base_dir )
4747
4848 if command == "clone" :
49+ if len (sys .argv ) != 3 :
50+ raise ValueError (
51+ "You provided an incorrect number of arguments.\n Usage: commit0 clone {repo_split}"
52+ )
4953 commit0 .harness .setup .main (
5054 config .dataset_name ,
5155 config .dataset_split ,
5256 config .repo_split ,
5357 config .base_dir ,
5458 )
5559 elif command == "build" :
60+ if len (sys .argv ) != 3 :
61+ raise ValueError (
62+ "You provided an incorrect number of arguments.\n Usage: commit0 build {repo_split}"
63+ )
5664 commit0 .harness .build .main (
5765 config .dataset_name ,
5866 config .dataset_split ,
@@ -61,30 +69,26 @@ def main() -> None:
6169 config .backend ,
6270 )
6371 elif command == "get-tests" :
72+ if len (sys .argv ) != 3 :
73+ raise ValueError (
74+ "You provided an incorrect number of arguments.\n Usage: commit0 get-tests {repo_name}"
75+ )
6476 repo = sys .argv [2 ]
6577 commit0 .harness .get_pytest_ids .main (repo , stdout = True )
6678 elif command == "test" or command == "test-reference" :
6779 # this command assume execution in arbitrary working directory
6880 repo_or_repo_path = sys .argv [2 ]
6981 if command == "test-reference" :
70- if len (sys .argv ) < 4 :
82+ if len (sys .argv ) != 4 :
7183 raise ValueError (
72- "An argument is missing for commit0 test-reference.\n Usage: commit0 test-reference {repo_dir} {test_ids}"
73- )
74- elif len (sys .argv ) > 4 :
75- raise ValueError (
76- "Too many arguments are passed to commit0 test-reference.\n Usage: commit0 test-reference {repo_dir} {test_ids}"
84+ "You provided an incorrect number of arguments.\n Usage: commit0 test-reference {repo_dir} {test_ids}"
7785 )
7886 branch = "reference"
7987 test_ids = sys .argv [3 ]
8088 else :
81- if len (sys .argv ) < 5 :
82- raise ValueError (
83- "An argument is missing for commit0 test.\n Usage: commit0 test {repo_dir} {branch} {test_ids}"
84- )
85- elif len (sys .argv ) > 5 :
89+ if len (sys .argv ) != 5 :
8690 raise ValueError (
87- "Too many arguments are passed to commit0 test .\n Usage: commit0 test {repo_dir} {branch} {test_ids}"
91+ "You provided an incorrect number of arguments .\n Usage: commit0 test {repo_dir} {branch} {test_ids}"
8892 )
8993 branch = sys .argv [3 ]
9094 test_ids = sys .argv [4 ]
@@ -104,23 +108,15 @@ def main() -> None:
104108 )
105109 elif command == "evaluate" or command == "evaluate-reference" :
106110 if command == "evaluate-reference" :
107- if len (sys .argv ) < 3 :
108- raise ValueError (
109- "An argument is missing for commit0 evaluate-reference.\n Usage: commit0 evaluate-reference {repo_split}"
110- )
111- elif len (sys .argv ) > 3 :
111+ if len (sys .argv ) != 3 :
112112 raise ValueError (
113- "Too many arguments are passed to commit0 evaluate-reference .\n Usage: commit0 evaluate-reference {repo_split}"
113+ "You provided an incorrect number of arguments .\n Usage: commit0 evaluate-reference {repo_split}"
114114 )
115115 branch = "reference"
116116 else :
117- if len (sys .argv ) < 4 :
117+ if len (sys .argv ) != 4 :
118118 raise ValueError (
119- "An argument is missing for commit0 evaluate.\n Usage: commit0 evaluate {repo_split} {branch}"
120- )
121- elif len (sys .argv ) > 4 :
122- raise ValueError (
123- "Too many arguments are passed to commit0 evaluate.\n Usage: commit0 evaluate {repo_split} {branch}"
119+ "You provided an incorrect number of arguments.\n Usage: commit0 evaluate {repo_split} {branch}"
124120 )
125121 branch = sys .argv [3 ]
126122 if branch .startswith ("branch=" ):
@@ -137,14 +133,21 @@ def main() -> None:
137133 config .num_workers ,
138134 )
139135 elif command == "save" :
140- organization = sys .argv [3 ]
136+ if len (sys .argv ) != 5 :
137+ raise ValueError (
138+ "You provided an incorrect number of arguments.\n Usage: commit0 save {repo_split} {owner} {branch}"
139+ )
140+ owner = sys .argv [3 ]
141+ branch = sys .argv [4 ]
142+ if branch .startswith ("branch=" ):
143+ branch = branch [len ("branch=" ) :]
141144 commit0 .harness .save .main (
142145 config .dataset_name ,
143146 config .dataset_split ,
144147 config .repo_split ,
145148 config .base_dir ,
146- organization ,
147- config . branch ,
149+ owner ,
150+ branch ,
148151 config .github_token ,
149152 )
150153
0 commit comments