File tree Expand file tree Collapse file tree 3 files changed +13
-32
lines changed Expand file tree Collapse file tree 3 files changed +13
-32
lines changed Original file line number Diff line number Diff line change @@ -16,19 +16,14 @@ pub enum Commands {
1616 #[ command( visible_alias = "-a" ) ]
1717 Auth ,
1818 /// Executes code with testcases
19- #[ command( visible_alias = "-rt" ) ]
20- RunCustom {
21- /// Testcases to run
22- testcases : String ,
23- #[ arg( short, long) ]
24- /// File to execute
25- file : Option < PathBuf > ,
26- } ,
2719 #[ command( visible_alias = "-r" ) ]
2820 Run {
2921 #[ arg( short, long) ]
30- /// File to execute with default testcases
22+ /// File to execute
3123 file : Option < PathBuf > ,
24+ #[ arg( short, long) ]
25+ /// Testcases to run
26+ testcase_file : Option < String > ,
3227 } ,
3328 /// Submits code to LeetCode
3429 #[ command( visible_alias = "-fs" ) ]
@@ -42,6 +37,9 @@ pub enum Commands {
4237 #[ arg( short, long) ]
4338 /// File to submit
4439 file : Option < PathBuf > ,
40+ #[ arg( short, long) ]
41+ /// Testcases to run
42+ testcase_file : Option < String > ,
4543 } ,
4644 /// Save a question as HTML
4745 #[ command( visible_alias = "-q" ) ]
@@ -60,16 +58,3 @@ pub enum Commands {
6058 file : Option < PathBuf > ,
6159 } ,
6260}
63-
64- #[ derive( Subcommand ) ]
65- pub enum Execute {
66- #[ command( visible_alias = "-t" ) ]
67- Testcases {
68- #[ arg( short, long) ]
69- /// File to run
70- file : Option < PathBuf > ,
71- #[ arg( short, long) ]
72- /// Testcases to run
73- testcases : Option < String > ,
74- } ,
75- }
Original file line number Diff line number Diff line change @@ -66,12 +66,8 @@ fn main() -> Result<()> {
6666 println ! ( "Saved question as HTML to {}" , filename. cyan( ) ) ;
6767 open:: that ( filename) ?;
6868 }
69- Some ( Commands :: RunCustom { testcases, file } ) => {
70- _ = execute_testcases ( file, Some ( & testcases) , & lc) ?;
71- // bail if `is_correct == false`?
72- }
73- Some ( Commands :: Run { file } ) => {
74- _ = execute_testcases ( file, None , & lc) ?;
69+ Some ( Commands :: Run { file, testcase_file : testcases } ) => {
70+ execute_testcases ( file, testcases, & lc) ?;
7571 }
7672 Some ( Commands :: FastSubmit { file } ) => {
7773 let code_file = if let Some ( path) = file {
@@ -82,8 +78,8 @@ fn main() -> Result<()> {
8278
8379 submit ( & lc, code_file) ?;
8480 }
85- Some ( Commands :: Submit { file } ) => {
86- let ( is_correct, code_file) = execute_testcases ( file, None , & lc) ?;
81+ Some ( Commands :: Submit { file, testcase_file : testcases } ) => {
82+ let ( is_correct, code_file) = execute_testcases ( file, testcases , & lc) ?;
8783 if is_correct {
8884 submit ( & lc, code_file) ?;
8985 } else {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use eyre::{bail, Result};
1010/// The first element of the return tuple indicates whether the answer is correct.
1111pub ( crate ) fn execute_testcases < P : AsRef < Path > > (
1212 file_path : Option < P > ,
13- testcases : Option < & str > ,
13+ testcases : Option < String > ,
1414 lc : & LeetCode < Authorized > ,
1515) -> Result < ( bool , CodeFile ) > {
1616 let code_file = if let Some ( path) = file_path {
@@ -48,7 +48,7 @@ pub(crate) fn submit(lc: &LeetCode<Authorized>, code_file: CodeFile) -> Result<(
4848 SubmissionResult :: CompileError ( compile_err) => bail ! ( compile_err) ,
4949 SubmissionResult :: RuntimeError ( runtime_error) => bail ! ( runtime_error) ,
5050 SubmissionResult :: Wrong ( wrong) => bail ! ( wrong) ,
51- SubmissionResult :: Unknown ( _) => bail ! ( "Unknown error" ) ,
51+ SubmissionResult :: Unknown ( _) => bail ! ( "Unknown error occured " ) ,
5252 } ;
5353
5454 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments