@@ -9,6 +9,7 @@ use crate::cmd::{
9
9
} ;
10
10
use crate :: repo:: Module ;
11
11
12
+ use android_root:: module_state;
12
13
use clap:: { Parser , Subcommand } ;
13
14
use repo:: Repo ;
14
15
use std:: io:: Write ;
@@ -79,18 +80,18 @@ enum Commands {
79
80
/// Installs selected modules
80
81
ids : Vec < String > ,
81
82
} ,
82
- // Enable {
83
- // /// Enabled selected modules
84
- // ids: Vec<String>,
85
- // },
86
- // Disable {
87
- // /// Disabled selected modules
88
- // ids: Vec<String>,
89
- // },
90
- // Remove {
91
- // /// Remove selected modules
92
- // ids: Vec<String>,
93
- // },
83
+ Enable {
84
+ /// Enabled selected modules
85
+ ids : Vec < String > ,
86
+ } ,
87
+ Disable {
88
+ /// Disabled selected modules
89
+ ids : Vec < String > ,
90
+ } ,
91
+ Remove {
92
+ /// Remove selected modules
93
+ ids : Vec < String > ,
94
+ } ,
94
95
}
95
96
96
97
/// Magisk Module Repo Loader CLI
@@ -249,68 +250,31 @@ async fn main() {
249
250
}
250
251
exit ( 0 ) ;
251
252
}
252
- // Commands::Enable { ids } => {
253
- // let mut some_disabled= false;
254
- // for id in ids {
255
- // let module = find_module(json.clone(), id);
256
- // let disable = &format!("/data/adb/modules/{}/disable", module.id);
257
- // if !Path::new(&disable).exists() {
258
- // if !File::create(disable).is_err() {
259
- // some_disabled = true;
260
- // println!("{} has been disabled.", module.name);
261
- // }
262
- // }
263
- // }
264
- // if !some_disabled {
265
- // println!("Nothing were disabled");
266
- // }
267
- // }
268
- // Commands::Disable { ids } => {
269
- // let mut some_disabled= false;
270
- // for id in ids {
271
- // let module = find_module(&json, id);
272
- // let disable = Path::new("/data/abd/modules").join(module.id).join("disable");
273
- // if !disable.exists() {
274
- // let mut f = File::create(disable).unwrap();
275
- // match f.write_all(b"") {
276
- // Ok(addr) => {
277
- // some_disabled = true;
278
- // println!("{} will be removed.", module.name);
279
- // },
280
- // Err(err) => {
281
- // println!("{}", err);
282
- // exit(1);
283
- // },
284
- // }
285
- // }
286
- // }
287
- // if !some_disabled {
288
- // println!("Nothing were disabled");
289
- // }
290
- // }
291
- // Commands::Remove { ids } => {
292
- // let mut some_removed= false;
293
- // for id in ids {
294
- // let module = find_module(&json, id);
253
+ Commands :: Enable { ids } => {
254
+ for id in ids {
255
+ let base_path = Path :: new ( "/data/adb/modules" ) . join ( id) ;
256
+ let disable = base_path. join ( "disable" ) ;
257
+ let remove = base_path. join ( "remove" ) ;
295
258
296
- // // let remove = Path::new("/data/adb/modules/");
259
+ if disable. exists ( ) {
260
+ fs:: remove_file ( disable) . expect ( "File delete failed" ) ;
261
+ }
297
262
298
- // // let gg = remove.join(module.id).join("remove");
299
- // // println!("{:?}", gg);
300
- // // if !remove.exists() {
301
- // // match fs::write(remove, b"Lorem ipsum") {
302
- // // Ok(addr) => {
303
- // // some_removed = true;
304
- // // println!("{} will be removed.", module.name);
305
- // // },
306
- // // Err(_) => (),
307
- // // }
308
- // // }
309
- // }
310
- // if !some_removed {
311
- // println!("Nothing were removed");
312
- // }
313
- // }
263
+ if remove. exists ( ) {
264
+ fs:: remove_file ( remove) . expect ( "File delete failed" ) ;
265
+ }
266
+ }
267
+ }
268
+ Commands :: Disable { ids } => {
269
+ for id in ids {
270
+ module_state ( id, "disable" ) ;
271
+ }
272
+ }
273
+ Commands :: Remove { ids } => {
274
+ for id in ids {
275
+ module_state ( id, "remove" ) ;
276
+ }
277
+ }
314
278
Commands :: Download { ids } => {
315
279
for id in ids {
316
280
download ( client. clone ( ) , & modules, id) . await ;
0 commit comments