@@ -215,17 +215,17 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> {
215215 println ! ( "{} {}" , "Unknown file:" . yellow( ) , filename. dimmed( ) ) ;
216216 }
217217 ( _, Some ( mr_id) , None ) => {
218- send_ids. push ( ModIdentifier :: ModrinthProject ( mr_id) ) ;
218+ send_ids. push ( ModIdentifier :: ModrinthProject ( mr_id, None ) ) ;
219219 }
220220 ( _, None , Some ( cf_id) ) => {
221- send_ids. push ( ModIdentifier :: CurseForgeProject ( cf_id) ) ;
221+ send_ids. push ( ModIdentifier :: CurseForgeProject ( cf_id, None ) ) ;
222222 }
223223 ( _, Some ( mr_id) , Some ( cf_id) ) => match platform {
224224 cli:: Platform :: Modrinth => {
225- send_ids. push ( ModIdentifier :: ModrinthProject ( mr_id) ) ;
225+ send_ids. push ( ModIdentifier :: ModrinthProject ( mr_id, None ) ) ;
226226 }
227227 cli:: Platform :: Curseforge => {
228- send_ids. push ( ModIdentifier :: CurseForgeProject ( cf_id) ) ;
228+ send_ids. push ( ModIdentifier :: CurseForgeProject ( cf_id, None ) ) ;
229229 }
230230 } ,
231231 }
@@ -240,50 +240,23 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> {
240240 SubCommands :: Add {
241241 identifiers,
242242 force,
243- pin,
244243 filters,
245244 } => {
246245 let profile = get_active_profile ( & mut config) ?;
247246 let override_profile = filters. override_profile ;
248247 let filters: Vec < _ > = filters. into ( ) ;
249248
249+ // TODO: conf multiple filters if the user sets the option
250250 ensure ! (
251251 // If filters are specified, there should only be one mod
252252 filters. is_empty( ) || identifiers. len( ) == 1 ,
253253 "You can only configure filters when adding a single mod!"
254254 ) ;
255- ensure ! (
256- // If a pin is specified, there should only be one mod
257- pin. is_none( ) || identifiers. len( ) == 1 ,
258- "You can only pin a version when adding a single mod!"
259- ) ;
260255
261- let identifiers = if let Some ( pin) = pin {
262- let id = libium:: add:: parse_id ( identifiers[ 0 ] . clone ( ) ) ;
263- vec ! [ match id {
264- ModIdentifier :: CurseForgeProject ( project_id) => {
265- ModIdentifier :: PinnedCurseForgeProject (
266- project_id,
267- pin. parse( ) . context( "Invalid file ID for CurseForge file" ) ?,
268- )
269- }
270- ModIdentifier :: ModrinthProject ( project_id) => {
271- ModIdentifier :: PinnedModrinthProject ( project_id, pin)
272- }
273- ModIdentifier :: GitHubRepository ( owner, repo) => {
274- ModIdentifier :: PinnedGitHubRepository (
275- ( owner, repo) ,
276- pin. parse( ) . context( "Invalid asset ID for GitHub" ) ?,
277- )
278- }
279- _ => unreachable!( ) ,
280- } ]
281- } else {
282- identifiers
283- . into_iter ( )
284- . map ( libium:: add:: parse_id)
285- . collect_vec ( )
286- } ;
256+ let identifiers = identifiers
257+ . into_iter ( )
258+ . map ( libium:: add:: parse_id)
259+ . collect :: < libium:: add:: Result < Vec < _ > > > ( ) ?;
287260
288261 let ( successes, failures) =
289262 libium:: add ( profile, identifiers, !force, override_profile, filters) . await ?;
@@ -317,21 +290,28 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> {
317290 ) ;
318291 for mod_ in & profile. mods {
319292 println ! (
320- "{:20} {}" ,
293+ "{:20} {}{} " ,
321294 match & mod_. identifier {
322- ModIdentifier :: CurseForgeProject ( id) =>
295+ ModIdentifier :: CurseForgeProject ( id, _ ) =>
323296 format!( "{} {:8}" , "CF" . red( ) , id. to_string( ) . dimmed( ) ) ,
324- ModIdentifier :: ModrinthProject ( id) =>
297+ ModIdentifier :: ModrinthProject ( id, _ ) =>
325298 format!( "{} {:8}" , "MR" . green( ) , id. dimmed( ) ) ,
326299 ModIdentifier :: GitHubRepository ( ..) => "GH" . purple( ) . to_string( ) ,
327- _ => todo!( ) ,
328300 } ,
329301 match & mod_. identifier {
330- ModIdentifier :: ModrinthProject ( _ )
331- | ModIdentifier :: CurseForgeProject ( _ ) => mod_. name. bold( ) . to_string( ) ,
332- ModIdentifier :: GitHubRepository ( owner, repo) =>
302+ ModIdentifier :: ModrinthProject ( .. )
303+ | ModIdentifier :: CurseForgeProject ( .. ) => mod_. name. bold( ) . to_string( ) ,
304+ ModIdentifier :: GitHubRepository ( ( owner, repo) , _ ) =>
333305 format!( "{}/{}" , owner. dimmed( ) , repo. bold( ) ) ,
334- _ => todo!( ) ,
306+ } ,
307+ match & mod_. identifier {
308+ ModIdentifier :: ModrinthProject ( _, Some ( pin) ) =>
309+ format!( "\n 📌 {}" , pin. dimmed( ) ) ,
310+ ModIdentifier :: CurseForgeProject ( _, Some ( pin) ) =>
311+ format!( "\n 📌 {}" , pin. to_string( ) . dimmed( ) ) ,
312+ ModIdentifier :: GitHubRepository ( _, Some ( pin) ) =>
313+ format!( "\n 📌 {}" , pin. to_string( ) . dimmed( ) ) ,
314+ _ => String :: new( ) ,
335315 } ,
336316 ) ;
337317 }
0 commit comments