Skip to content

Commit 27c47b0

Browse files
authored
cf: provide file download page for manual ones (#331)
1 parent 0033826 commit 27c47b0

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

src/main/java/me/itzg/helpers/curseforge/InstallCurseForgeCommand.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import me.itzg.helpers.http.PathOrUriConverter;
2020
import me.itzg.helpers.http.SharedFetchArgs;
2121
import me.itzg.helpers.json.ObjectMappers;
22+
import org.jetbrains.annotations.NotNull;
2223
import picocli.CommandLine.ArgGroup;
2324
import picocli.CommandLine.Command;
2425
import picocli.CommandLine.ExitCode;
@@ -208,15 +209,7 @@ public Integer call() throws Exception {
208209
return ExitCode.OK;
209210
} catch (MissingModsException e) {
210211

211-
final TabularOutput tabOut = new TabularOutput('=', " ", "Mod", "Slug", "Filename", "Download page");
212-
for (PathWithInfo info : e.getNeedsDownload()) {
213-
tabOut.addRow(
214-
info.getModInfo().getName(),
215-
info.getModInfo().getSlug(),
216-
info.getCurseForgeFile().getDisplayName(),
217-
info.getModInfo().getLinks().getWebsiteUrl()
218-
);
219-
}
212+
final TabularOutput tabOut = buildTabularOutput(e);
220213

221214
if (needsDownloadFile != null) {
222215
try (BufferedWriter writer = Files.newBufferedWriter(needsDownloadFile)) {
@@ -240,6 +233,21 @@ public Integer call() throws Exception {
240233

241234
}
242235

236+
@NotNull
237+
private static TabularOutput buildTabularOutput(MissingModsException e) {
238+
final TabularOutput tabOut = new TabularOutput('=', " ",
239+
"Mod", "Filename", "Download page"
240+
);
241+
for (PathWithInfo info : e.getNeedsDownload()) {
242+
tabOut.addRow(
243+
info.getModInfo().getName(),
244+
info.getCurseForgeFile().getDisplayName(),
245+
info.getModInfo().getLinks().getWebsiteUrl() + "/files/" + info.getCurseForgeFile().getId()
246+
);
247+
}
248+
return tabOut;
249+
}
250+
243251
private ExcludeIncludesContent loadExcludeIncludes() throws IOException {
244252
final ExcludeIncludesContent fromFile =
245253
excludeIncludeArgs.excludeIncludeFile != null ? loadExcludeIncludesFile()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* This package provides wrappers of <a href="https://projectreactor.io/docs/netty/release/reference/index.html">Reactor Netty</a>
3+
* to simplify common retrieval patterns such as
4+
* <ul>
5+
* <li>parsing response JSON into Java objects</li>
6+
* <li>retrieving a file into a known output name with handling of up to date checks</li>
7+
* <li>retrieving a file without prior knowledge of the resulting filename</li>
8+
* </ul>
9+
* Examples:
10+
* <pre>{@code
11+
* Fetch.fetch(URI.create(...))
12+
* .toDirectory(dest)
13+
* .skipUpToDate(true)
14+
* .assemble()
15+
* .block()
16+
* }</pre>
17+
*/
18+
package me.itzg.helpers.http;

0 commit comments

Comments
 (0)