z_mirror/fmm

git clone https://git.raiguard.me/z_mirror/fmm

raiguardRemove lib.rs, it's kinda useless here1363bd4

refactor
2.1 KiB91 linesraw
1#![feature(iter_intersperse)]
2
3use anyhow::Result;
4
5mod dependency;
6mod directory;
7mod input;
8mod sync;
9mod types;
10
11use input::{proc_input, Actions};
12
13fn main() -> Result<()> {
14    let (actions, config, directory) = proc_input()?;
15
16    println!("{:#?}", actions);
17    println!("{:#?}", config);
18
19    run(actions)?;
20
21    Ok(())
22}
23
24fn run(actions: Actions) -> Result<()> {
25    // // List mods
26    // if app.list {
27    //     let mut lines: Vec<String> = directory
28    //         .mods
29    //         .iter()
30    //         .flat_map(|(mod_name, mod_versions)| {
31    //             mod_versions
32    //                 .iter()
33    //                 .map(|version| format!("{} v{}", mod_name, version.version))
34    //                 .collect::<Vec<String>>()
35    //         })
36    //         .collect();
37
38    //     lines.sort();
39    //     lines.iter().for_each(|line| println!("{}", line));
40    // }
41
42    // // Sync with save
43    // if let Some(sync_path) = app.sync {
44    //     let save_file = sync::SaveFile::from(sync_path)?;
45
46    //     app.enable = save_file.mods;
47    // }
48
49    // // Remove specified mods
50    // for mod_ident in app.remove {
51    //     if mod_ident.name != "base" {
52    //         directory.remove(&mod_ident);
53    //     }
54    // }
55
56    // // Disable all mods
57    // if app.disable_all {
58    //     directory.disable_all();
59    // }
60
61    // // Disable specified mods
62    // for mod_ident in app.disable {
63    //     directory.disable(&mod_ident);
64    // }
65
66    // // Enable all mods
67    // if app.enable_all {
68    //     directory.enable_all();
69    // }
70
71    // // Enable specified mods
72    // let mut to_enable = app.enable;
73    // while !to_enable.is_empty() {
74    //     to_enable = to_enable
75    //         .iter_mut()
76    //         .filter(|mod_ident| mod_ident.name != "base")
77    //         .filter_map(|mod_ident| directory.enable(mod_ident))
78    //         .flatten()
79    //         .collect();
80    // }
81
82    // // Write mod-list.json
83    // fs::write(
84    //     &directory.mod_list_path,
85    //     serde_json::to_string_pretty(&ModListJson {
86    //         mods: directory.mod_list,
87    //     })?,
88    // )?;
89
90    Ok(())
91}