diff options
Diffstat (limited to 'src/commands/io.rs')
-rw-r--r-- | src/commands/io.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/commands/io.rs b/src/commands/io.rs index 2a26f1d..43e642a 100644 --- a/src/commands/io.rs +++ b/src/commands/io.rs | |||
@@ -21,9 +21,9 @@ struct ExportVersion { | |||
21 | } | 21 | } |
22 | 22 | ||
23 | impl ExportVersion { | 23 | impl ExportVersion { |
24 | fn from(config: Cfg, list_id: &str, mod_id: &str) -> MLE<Self> { | 24 | fn from(config: &Cfg, list_id: &str, mod_id: &str) -> MLE<Self> { |
25 | Ok(Self { | 25 | Ok(Self { |
26 | version: userlist_get_current_version(config.clone(), list_id, mod_id)?, | 26 | version: userlist_get_current_version(config, list_id, mod_id)?, |
27 | set: userlist_get_set_version(config, list_id, mod_id)? | 27 | set: userlist_get_set_version(config, list_id, mod_id)? |
28 | }) | 28 | }) |
29 | } | 29 | } |
@@ -39,18 +39,18 @@ struct ExportList { | |||
39 | } | 39 | } |
40 | 40 | ||
41 | impl ExportList { | 41 | impl ExportList { |
42 | pub fn from(config: Cfg, list_id: String, download: bool) -> MLE<Self> { | 42 | pub fn from(config: &Cfg, list_id: String, download: bool) -> MLE<Self> { |
43 | let list = lists_get(config.clone(), String::from(&list_id))?; | 43 | let list = lists_get(config, String::from(&list_id))?; |
44 | 44 | ||
45 | let mut dl_folder = None; | 45 | let mut dl_folder = None; |
46 | if download { | 46 | if download { |
47 | dl_folder = Some(list.download_folder) | 47 | dl_folder = Some(list.download_folder) |
48 | }; | 48 | }; |
49 | 49 | ||
50 | let mods = userlist_get_all_ids(config.clone(), &list_id)?; | 50 | let mods = userlist_get_all_ids(config, &list_id)?; |
51 | let mut versions = vec![]; | 51 | let mut versions = vec![]; |
52 | for m in mods { | 52 | for m in mods { |
53 | versions.push(ExportVersion::from(config.clone(), &list_id, &m)?) | 53 | versions.push(ExportVersion::from(config, &list_id, &m)?) |
54 | } | 54 | } |
55 | 55 | ||
56 | Ok(Self { | 56 | Ok(Self { |
@@ -63,16 +63,16 @@ impl ExportList { | |||
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | pub fn export(config: Cfg, list: Option<String>) -> MLE<()> { | 66 | pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> { |
67 | let mut list_ids: Vec<String> = vec![]; | 67 | let mut list_ids: Vec<String> = vec![]; |
68 | if list.is_none() { | 68 | if list.is_none() { |
69 | list_ids = lists_get_all_ids(config.clone())?; | 69 | list_ids = lists_get_all_ids(config)?; |
70 | } else { | 70 | } else { |
71 | list_ids.push(lists_get(config.clone(), list.unwrap())?.id); | 71 | list_ids.push(lists_get(config, list.unwrap())?.id); |
72 | } | 72 | } |
73 | let mut lists: Vec<ExportList> = vec![]; | 73 | let mut lists: Vec<ExportList> = vec![]; |
74 | for list_id in list_ids { | 74 | for list_id in list_ids { |
75 | lists.push(ExportList::from(config.clone(), list_id, true)?); | 75 | lists.push(ExportList::from(config, list_id, true)?); |
76 | } | 76 | } |
77 | 77 | ||
78 | let toml = toml::to_string(&Export { lists })?; | 78 | let toml = toml::to_string(&Export { lists })?; |
@@ -85,7 +85,7 @@ pub fn export(config: Cfg, list: Option<String>) -> MLE<()> { | |||
85 | Ok(()) | 85 | Ok(()) |
86 | } | 86 | } |
87 | 87 | ||
88 | pub async fn import(config: Cfg, file_str: String, direct_download: bool) -> MLE<()> { | 88 | pub async fn import(config: &Cfg, file_str: String, direct_download: bool) -> MLE<()> { |
89 | let mut file = File::open(file_str)?; | 89 | let mut file = File::open(file_str)?; |
90 | let mut content = String::new(); | 90 | let mut content = String::new(); |
91 | file.read_to_string(&mut content)?; | 91 | file.read_to_string(&mut content)?; |
@@ -99,18 +99,18 @@ pub async fn import(config: Cfg, file_str: String, direct_download: bool) -> MLE | |||
99 | download_folder: exportlist.download_folder.ok_or("NO_DL").unwrap(), | 99 | download_folder: exportlist.download_folder.ok_or("NO_DL").unwrap(), |
100 | }; | 100 | }; |
101 | lists_insert( | 101 | lists_insert( |
102 | config.clone(), | 102 | config, |
103 | list.id.clone(), | 103 | &list.id, |
104 | list.mc_version.clone(), | 104 | &list.mc_version, |
105 | list.modloader.clone(), | 105 | &list.modloader, |
106 | String::from(&list.download_folder), | 106 | &list.download_folder, |
107 | )?; | 107 | )?; |
108 | 108 | ||
109 | let mut ver_ids = vec![]; | 109 | let mut ver_ids = vec![]; |
110 | for id in exportlist.versions { | 110 | for id in exportlist.versions { |
111 | ver_ids.push(AddMod { id: IDSelector::VersionID(id.version), set_version: id.set} ); | 111 | ver_ids.push(AddMod { id: IDSelector::VersionID(id.version), set_version: id.set} ); |
112 | } | 112 | } |
113 | mod_add(config.clone(), ver_ids, list, direct_download).await?; | 113 | mod_add(config, ver_ids, list, direct_download).await?; |
114 | } | 114 | } |
115 | Ok(()) | 115 | Ok(()) |
116 | } | 116 | } |