@@ -50,35 +50,36 @@ pub fn extract_project_overwrite(
5050/// See `LanguagePlugin::compress_project`.
5151// TODO: clean up
5252pub fn compress_project_to_zip ( path : & Path ) -> Result < Vec < u8 > , PluginError > {
53- match get_language_plugin_type ( path) ? {
54- PluginType :: CSharp => Ok ( tmc_zip:: zip_student_files (
53+ match get_language_plugin_type ( path) {
54+ Some ( PluginType :: CSharp ) => Ok ( tmc_zip:: zip_student_files (
5555 <CSharpPlugin as LanguagePlugin >:: StudentFilePolicy :: new ( path) ?,
5656 path,
5757 ) ?) ,
58- PluginType :: Make => Ok ( tmc_zip:: zip_student_files (
58+ Some ( PluginType :: Make ) => Ok ( tmc_zip:: zip_student_files (
5959 <MakePlugin as LanguagePlugin >:: StudentFilePolicy :: new ( path) ?,
6060 path,
6161 ) ?) ,
62- PluginType :: Maven => Ok ( tmc_zip:: zip_student_files (
62+ Some ( PluginType :: Maven ) => Ok ( tmc_zip:: zip_student_files (
6363 <MavenPlugin as LanguagePlugin >:: StudentFilePolicy :: new ( path) ?,
6464 path,
6565 ) ?) ,
66- PluginType :: NoTests => Ok ( tmc_zip:: zip_student_files (
66+ Some ( PluginType :: NoTests ) => Ok ( tmc_zip:: zip_student_files (
6767 <NoTestsPlugin as LanguagePlugin >:: StudentFilePolicy :: new ( path) ?,
6868 path,
6969 ) ?) ,
70- PluginType :: Python3 => Ok ( tmc_zip:: zip_student_files (
70+ Some ( PluginType :: Python3 ) => Ok ( tmc_zip:: zip_student_files (
7171 <Python3Plugin as LanguagePlugin >:: StudentFilePolicy :: new ( path) ?,
7272 path,
7373 ) ?) ,
74- PluginType :: R => Ok ( tmc_zip:: zip_student_files (
74+ Some ( PluginType :: R ) => Ok ( tmc_zip:: zip_student_files (
7575 <RPlugin as LanguagePlugin >:: StudentFilePolicy :: new ( path) ?,
7676 path,
7777 ) ?) ,
78- PluginType :: Ant => Ok ( tmc_zip:: zip_student_files (
78+ Some ( PluginType :: Ant ) => Ok ( tmc_zip:: zip_student_files (
7979 <AntPlugin as LanguagePlugin >:: StudentFilePolicy :: new ( path) ?,
8080 path,
8181 ) ?) ,
82+ None => Err ( PluginError :: PluginNotFound ( path. to_path_buf ( ) ) ) ,
8283 }
8384}
8485
@@ -113,7 +114,7 @@ pub enum PluginType {
113114 Ant ,
114115}
115116
116- pub fn get_language_plugin_type ( path : & Path ) -> Result < PluginType , PluginError > {
117+ pub fn get_language_plugin_type ( path : & Path ) -> Option < PluginType > {
117118 let plugin_type = if NoTestsPlugin :: is_exercise_type_correct ( path) {
118119 log:: info!(
119120 "Detected project at {} as {}" ,
@@ -165,21 +166,22 @@ pub fn get_language_plugin_type(path: &Path) -> Result<PluginType, PluginError>
165166 ) ;
166167 PluginType :: Ant
167168 } else {
168- return Err ( PluginError :: PluginNotFound ( path . to_path_buf ( ) ) ) ;
169+ return None ;
169170 } ;
170- Ok ( plugin_type)
171+ Some ( plugin_type)
171172}
172173
173174// Get language plugin for the given path.
174175pub fn get_language_plugin ( path : & Path ) -> Result < Plugin , PluginError > {
175- let plugin = match get_language_plugin_type ( path) ? {
176- PluginType :: NoTests => Plugin :: NoTests ( NoTestsPlugin :: new ( ) ) ,
177- PluginType :: CSharp => Plugin :: CSharp ( CSharpPlugin :: new ( ) ) ,
178- PluginType :: Make => Plugin :: Make ( MakePlugin :: new ( ) ) ,
179- PluginType :: Python3 => Plugin :: Python3 ( Python3Plugin :: new ( ) ) ,
180- PluginType :: R => Plugin :: R ( RPlugin :: new ( ) ) ,
181- PluginType :: Maven => Plugin :: Maven ( MavenPlugin :: new ( ) ?) ,
182- PluginType :: Ant => Plugin :: Ant ( AntPlugin :: new ( ) ?) ,
176+ let plugin = match get_language_plugin_type ( path) {
177+ Some ( PluginType :: NoTests ) => Plugin :: NoTests ( NoTestsPlugin :: new ( ) ) ,
178+ Some ( PluginType :: CSharp ) => Plugin :: CSharp ( CSharpPlugin :: new ( ) ) ,
179+ Some ( PluginType :: Make ) => Plugin :: Make ( MakePlugin :: new ( ) ) ,
180+ Some ( PluginType :: Python3 ) => Plugin :: Python3 ( Python3Plugin :: new ( ) ) ,
181+ Some ( PluginType :: R ) => Plugin :: R ( RPlugin :: new ( ) ) ,
182+ Some ( PluginType :: Maven ) => Plugin :: Maven ( MavenPlugin :: new ( ) ?) ,
183+ Some ( PluginType :: Ant ) => Plugin :: Ant ( AntPlugin :: new ( ) ?) ,
184+ None => return Err ( PluginError :: PluginNotFound ( path. to_path_buf ( ) ) ) ,
183185 } ;
184186 Ok ( plugin)
185187}
0 commit comments