Skip to content

Commit 65816a0

Browse files
Remove mods by their slugs (#462)
* Remove mods by their slugs - Adds removing mods by their slugs - Fetches slugs and updates older configs when using `list --verbose` Fixes #439 * Fixed cargo clippy complaining Fixed cargo clippy complaining about enum sizes, an oversight since I had an older version of clippy and it didn't catch the issue. * Update libium commit hash and use `is_some_and` --------- Co-authored-by: Ilesh Thiada <[email protected]>
1 parent 42e5bf9 commit 65816a0

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fs_extra = "1.3"
6161
ferinth = "2.11"
6262
colored = "3.0"
6363
inquire = "0.7"
64-
libium = { git = "https://github.com/gorilla-devs/libium", rev = "e043a6e17a475158a595cfcf1767ef81521d0587" }
64+
libium = { git = "https://github.com/gorilla-devs/libium", rev = "eed35ae6b695a93b9e26b59974a2b26fe3ac7407" }
6565
# libium = { path = "../libium" }
6666
# libium = "1.32"
6767
anyhow = "1.0"

src/subcommands/list.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use tokio::task::JoinSet;
1414
enum Metadata {
1515
CF(Mod),
1616
MD(Project, Vec<TeamMember>),
17-
GH(Repository, Vec<Release>),
17+
GH(Box<Repository>, Vec<Release>),
1818
}
1919
impl Metadata {
2020
fn name(&self) -> &str {
@@ -35,6 +35,14 @@ impl Metadata {
3535
}
3636
}
3737
}
38+
39+
fn slug(&self) -> &str {
40+
match self {
41+
Metadata::CF(p) => &p.slug,
42+
Metadata::MD(p, _) => &p.slug,
43+
Metadata::GH(p, _) => &p.name,
44+
}
45+
}
3846
}
3947

4048
pub async fn verbose(profile: &mut Profile, markdown: bool) -> Result<()> {
@@ -92,7 +100,7 @@ pub async fn verbose(profile: &mut Profile, markdown: bool) -> Result<()> {
92100
}
93101
for res in tasks.join_all().await {
94102
let (repo, releases) = res?;
95-
metadata.push(Metadata::GH(repo, releases.items));
103+
metadata.push(Metadata::GH(Box::new(repo), releases.items));
96104
}
97105
metadata.sort_unstable_by_key(|e| e.name().to_lowercase());
98106

@@ -101,12 +109,14 @@ pub async fn verbose(profile: &mut Profile, markdown: bool) -> Result<()> {
101109
}
102110

103111
for project in &metadata {
104-
profile
112+
let mod_ = profile
105113
.mods
106114
.iter_mut()
107115
.find(|mod_| mod_.identifier == project.id())
108-
.context("Could not find expected mod")?
109-
.name = project.name().to_string();
116+
.context("Could not find expected mod")?;
117+
118+
mod_.name = project.name().to_string();
119+
mod_.slug = Some(project.slug().to_string());
110120

111121
if markdown {
112122
match project {

src/subcommands/remove.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ pub fn remove(profile: &mut Profile, to_remove: Vec<String>) -> Result<()> {
5151
}
5252
_ => todo!(),
5353
}
54+
|| mod_
55+
.slug
56+
.as_ref()
57+
.is_some_and(|slug| to_remove.eq_ignore_ascii_case(slug))
5458
}) {
5559
items_to_remove.push(index);
5660
} else {

0 commit comments

Comments
 (0)