Added the list and remove command

This commit is contained in:
2024-06-03 13:51:59 +02:00
parent 56f659a182
commit 846b3d0edf
6 changed files with 107 additions and 14 deletions

View File

@@ -1,17 +1,23 @@
use crate::{config, modrinth::project::get_multiple_projects};
use crate::{config, pack::Modpack};
use colored::*;
use comfy_table::{presets::NOTHING, Table};
pub async fn list() {
let config = config::Config::get().unwrap();
let projects = get_multiple_projects(config.projects.keys().to_owned().collect())
.await
.unwrap();
let modpack = Modpack::from_config(&config).await.unwrap();
let rows: Vec<Vec<ColoredString>> = projects
.iter()
.map(|p| vec![p.title.bold(), p.id.dimmed()])
let rows: Vec<Vec<ColoredString>> = modpack
.mods
.values()
.into_iter()
.map(|p| {
vec![
p.title.bold(),
p.project_id.dimmed(),
p.version.as_ref().unwrap().version_number.normal(),
]
})
.collect();
let mut table = Table::new();