Skip to content

Commit f0b5519

Browse files
committed
add --pack cli command
1 parent b365334 commit f0b5519

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

repak-gui/src/install_mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ fn find_mods_from_archive(path: &str) -> Vec<InstallableMod> {
417417
new_mods
418418
}
419419

420-
fn map_to_mods_internal(paths: &[PathBuf]) -> Vec<InstallableMod> {
420+
pub fn map_to_mods_internal(paths: &[PathBuf]) -> Vec<InstallableMod> {
421421
let mut extensible_vec: Vec<InstallableMod> = Vec::new();
422422
let mut installable_mods = paths
423423
.iter()

repak-gui/src/main.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod ios_widget;
99
mod utoc_utils;
1010
mod welcome;
1111

12+
use crate::main_ui::RepakModManager;
1213
use eframe::egui::{self, IconData};
1314
use log::{info, LevelFilter};
1415
use retoc::{action_unpack, ActionUnpack, FGuid};
@@ -19,10 +20,11 @@ use std::fs::{create_dir, File};
1920
use std::path::PathBuf;
2021
use std::process::exit;
2122
use std::str::FromStr;
23+
use std::sync::atomic::AtomicI32;
2224
use std::sync::Arc;
2325

24-
use crate::main_ui::RepakModManager;
25-
26+
use crate::install_mod::install_mod_logic::iotoc::convert_directory_to_iostore;
27+
use crate::install_mod::map_to_mods_internal;
2628
#[cfg(target_os = "windows")]
2729
use {rfd::MessageButtons, std::panic::PanicHookInfo};
2830

@@ -121,6 +123,26 @@ fn main() {
121123
}
122124
exit(0);
123125
}
126+
if args[1] == "--pack" {
127+
let paths = args[2..]
128+
.iter()
129+
.map(|path| PathBuf::from_str(path).unwrap())
130+
.filter(|path| path.is_dir())
131+
.collect::<Vec<_>>();
132+
let installable_mods = map_to_mods_internal(&paths);
133+
for (i, installable) in installable_mods.iter().enumerate() {
134+
let mod_dir = paths[i].parent().unwrap();
135+
let count = AtomicI32::new(0);
136+
convert_directory_to_iostore(
137+
&installable,
138+
mod_dir.to_path_buf(),
139+
paths[i].clone(),
140+
&count,
141+
)
142+
.expect("Failed to convert directory");
143+
}
144+
exit(0);
145+
}
124146
}
125147

126148
// This forces repak gui to use the XWAYLAND backend instead of the wayland as wayland backend is half baked as shit

0 commit comments

Comments
 (0)