Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow skip on fail #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/kotlin/link/infra/packwiz/installer/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ class Main(args: Array<String>) {
cmd.getOptionValue("timeout")?.toLong() ?: 10
}

val skipOnFail = cmd.hasOption("skip-on-fail")

// Start update process!
try {
UpdateManager(UpdateManager.Options(packFile, manifestFile, packFolder, multimcFolder, side, timeout), ui)
UpdateManager(UpdateManager.Options(packFile, manifestFile, packFolder, multimcFolder, side, timeout, skipOnFail), ui)
} catch (e: Exception) {
ui.showErrorAndExit("Update process failed", e)
}
Expand All @@ -127,6 +129,7 @@ class Main(args: Array<String>) {
options.addOption(null, "multimc-folder", true, "The MultiMC pack folder (defaults to the parent of the pack directory)")
options.addOption(null, "meta-file", true, "JSON file to store pack metadata, relative to the pack folder (defaults to packwiz.json)")
options.addOption("t", "timeout", true, "Seconds to wait before automatically launching when asking about optional mods (defaults to 10)")
options.addOption(null, "skip-on-fail", false, "Skip the file if download fails instead of exiting")
}

// TODO: link these somehow so they're only defined once?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
val multimcFolder: PackwizFilePath,
val side: Side,
val timeout: Long,
val skipOnFail: Boolean
)

// TODO: make this return a value based on results?
Expand Down Expand Up @@ -446,7 +447,7 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
if (cfFiles.isNotEmpty()) {
ui.submitProgress(InstallProgress("Resolving CurseForge metadata..."))
val resolveFailures = resolveCfMetadata(cfFiles, opts.packFolder, clientHolder)
if (resolveFailures.isNotEmpty()) {
if (resolveFailures.isNotEmpty() && !opts.skipOnFail) {
errorsOccurred = true
return when (ui.showExceptions(resolveFailures, cfFiles.size, true)) {
ExceptionListResult.CONTINUE -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class CLIHandler : IUserInterface {
print(ex.name + ": ")
ex.exception.printStackTrace()
}
if (allowsIgnore) {
print("Do you want to ignore them and continue? (Y/N): ")
val input = readlnOrNull()
if (input.equals("Y", ignoreCase = true)) {
return ExceptionListResult.CONTINUE
}
}
return ExceptionListResult.CANCEL
}

Expand Down