Skip to content

Commit 327f273

Browse files
committed
local module install support
1 parent 30c229b commit 327f273

File tree

4 files changed

+77
-11
lines changed

4 files changed

+77
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Improved error handling
44
- Improved MMRL app support
55
- Added `repo` subcommand
6+
- Added support to install local modules
67
- Removed download progress bar due to deadlock in MMRL
78
- Other improvements
89
- Added ModConf

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Install a module with it
1414

1515
```shell
1616
# Install aliases are "add" and "get"
17-
mmrl install app-data-file-exec data_isolation_support
17+
mmrl install explore app-data-file-exec data_isolation_support
1818
```
1919

2020
## Get informations
@@ -54,15 +54,15 @@ mmrl download mkshrc node_on_android # --version 152
5454
Maybe simple...
5555

5656
```shell
57-
mmrl install mkshrc@1.3.4 node_on_android
57+
mmrl install explore mkshrc@1.3.4 node_on_android
5858
```
5959

6060
## Install Viper4Android
6161

6262
> Requires version `0.1.1`
6363
6464
```shell
65-
mmrl install -y "https://zackptg5.com/downloads/Audio-Modification-Library_v5.1.zip" "https://john-fawkes.com/Downloads/acp.zip" "https://github.com/AndroidAudioMods/ViPER4Android/releases/download/v0.5.0/V4A_Magisk_Module_0.5.0.zip"
65+
mmrl install explore -y "https://zackptg5.com/downloads/Audio-Modification-Library_v5.1.zip" "https://john-fawkes.com/Downloads/acp.zip" "https://github.com/AndroidAudioMods/ViPER4Android/releases/download/v0.5.0/V4A_Magisk_Module_0.5.0.zip"
6666
```
6767

6868
# Dev

src/cmd/install.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ use std::process::{exit, Command, Stdio};
1212
const METHOD_STORED: Option<zip::CompressionMethod> = Some(zip::CompressionMethod::Stored);
1313

1414
#[async_recursion]
15-
pub async fn install(client: Client, yes: bool, _requires: bool, modules: &Vec<Module>, id: String) {
15+
pub async fn install(
16+
client: Client,
17+
yes: bool,
18+
_requires: bool,
19+
modules: &Vec<Module>,
20+
id: String,
21+
) {
1622
let _url = &id.to_owned()[..];
1723
if is_url(_url) {
1824
let name = get_last(_url);
@@ -97,9 +103,39 @@ pub async fn install(client: Client, yes: bool, _requires: bool, modules: &Vec<M
97103
}
98104
}
99105
}
100-
exit(0);
101106
} else {
102107
exit(0);
103108
}
104109
}
105110
}
111+
112+
pub async fn install_local(yes: bool, id: String) -> () {
113+
let success = yes || confirm("Do you want to continue [y/N] ");
114+
115+
if success {
116+
let (bin, args) = get_install_cli(&id);
117+
118+
let stdout = Command::new(bin)
119+
.args(args)
120+
.stdout(Stdio::piped())
121+
.spawn()
122+
.unwrap()
123+
.stdout
124+
.ok_or_else(|| Error::new(ErrorKind::Other, "Could not capture standard output."))
125+
.unwrap();
126+
127+
let reader = BufReader::new(stdout);
128+
129+
for line in reader.lines() {
130+
match line {
131+
Ok(ln) => println!("{}", ln),
132+
Err(e) => {
133+
println!("{}", e);
134+
exit(500)
135+
}
136+
}
137+
}
138+
} else {
139+
exit(0);
140+
}
141+
}

src/main.rs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::repo::Module;
1111

1212
use android_root::module_state;
1313
use clap::{Parser, Subcommand};
14+
use cmd::install::install_local;
1415
use repo::Repo;
1516
use std::io::Write;
1617
use std::{
@@ -43,6 +44,19 @@ enum RepoCommands {
4344
Add { url: Vec<String> },
4445
}
4546

47+
#[derive(Debug, Subcommand)]
48+
enum InstallCommands {
49+
/// Install a local module
50+
#[command(arg_required_else_help = true, aliases = &["ll", "lcl"])]
51+
Local {
52+
/// Skip confirm
53+
#[arg(short, long)]
54+
yes: bool,
55+
/// Module ZIP location
56+
path: Vec<String>,
57+
},
58+
}
59+
4660
#[derive(Debug, Subcommand)]
4761
enum Commands {
4862
/// Update MMRL CLI
@@ -83,6 +97,8 @@ enum Commands {
8397
/// Install any module
8498
#[command(arg_required_else_help = true, aliases = &["add", "get", "fetch"])]
8599
Install {
100+
#[clap(subcommand)]
101+
commands: Option<InstallCommands>,
86102
/// Skip confirm
87103
#[arg(short, long)]
88104
yes: bool,
@@ -180,7 +196,7 @@ async fn main() {
180196
match args.commands {
181197
Commands::Repo { commands } => match commands {
182198
RepoCommands::Add { url } => {
183-
add(url);
199+
add(url).await;
184200
exit(0);
185201
}
186202
},
@@ -265,12 +281,25 @@ async fn main() {
265281
exit(0);
266282
}
267283
},
268-
Commands::Install { yes, requires, ids } => {
269-
for id in ids {
270-
install(client.clone(), yes, requires, &modules, id).await;
284+
Commands::Install {
285+
yes,
286+
requires,
287+
ids,
288+
commands,
289+
} => match commands {
290+
Some(InstallCommands::Local { yes, path }) => {
291+
for id in path {
292+
install_local(yes, id).await;
293+
}
294+
exit(0);
271295
}
272-
exit(0);
273-
}
296+
None => {
297+
for id in ids {
298+
install(client.clone(), yes, requires, &modules, id).await;
299+
}
300+
exit(0);
301+
}
302+
},
274303
Commands::Enable { ids } => {
275304
for id in ids {
276305
let base_path = Path::new("/data/adb/modules").join(id);

0 commit comments

Comments
 (0)