@@ -8,10 +8,12 @@ mod cli;
88mod config;
99mod eula;
1010mod get_files;
11+ mod modrinth;
12+ mod plugins;
1113mod software;
1214mod utils;
1315
14- use cli:: { CLI , Commands } ;
16+ use cli:: { CLI , Commands , PluginActions } ;
1517use config:: Config ;
1618use software:: Software ;
1719use utils:: { get_current_directory_name, get_executable_extension, inquired, print_error_and_exit} ;
@@ -167,6 +169,7 @@ fn handle_setup(
167169 software : software. clone ( ) ,
168170 minecraft_version : version. clone ( ) ,
169171 eula_accepted : eula,
172+ plugins : Vec :: new ( ) ,
170173 } ;
171174
172175 match config. save ( ) {
@@ -329,6 +332,19 @@ fn handle_upgrade(target_version: Option<String>) -> Result<(), Box<dyn std::err
329332 Ok ( ( ) )
330333}
331334
335+ async fn handle_plugins ( action : PluginActions ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
336+ match action {
337+ PluginActions :: List => plugins:: list_plugins ( ) . await ,
338+ PluginActions :: Add { name, force } => plugins:: get_plugin ( & name, force) . await ,
339+ PluginActions :: Load { config } => plugins:: load_plugins_from_config ( & config) . await ,
340+ PluginActions :: Update { target, force } => plugins:: update_plugins ( & target, force) . await ,
341+ PluginActions :: Remove { name } => plugins:: remove_plugin ( & name) . await ,
342+ PluginActions :: Search { query, limit } => plugins:: search_plugins ( & query, limit) . await ,
343+ PluginActions :: Info { name } => plugins:: show_plugin_info ( & name) . await ,
344+ PluginActions :: Export { output } => plugins:: export_plugins_config ( & output) . await ,
345+ }
346+ }
347+
332348fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
333349 let cli = CLI :: parse ( ) ;
334350
@@ -341,5 +357,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
341357 } => handle_setup ( software, mc_version, eula, yes) ,
342358 Commands :: Update => handle_update ( ) ,
343359 Commands :: Upgrade { version } => handle_upgrade ( version) ,
360+ Commands :: Plugins { action } => {
361+ let rt = tokio:: runtime:: Runtime :: new ( ) ?;
362+ rt. block_on ( handle_plugins ( action) )
363+ }
344364 }
345365}
0 commit comments