Skip to content

Commit

Permalink
additional open targets
Browse files Browse the repository at this point in the history
  • Loading branch information
ManApart committed Jun 19, 2024
1 parent 519b4c5 commit a187a42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/kotlin/commands/CommandType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ enum class CommandType(
INI_PATH("Open ini path folder", Category.OPEN, openDescription, "", ::openIniPath, "inipath"),
PLUGINS("Open plugins file", Category.OPEN, openDescription, "", ::openPluginsTxt, "plugin"),
JAR_PATH("Open jar path folder", Category.OPEN, openDescription, "", ::openJarPath, "jarpath"),
MANUAL("Open website manual", Category.OPEN, openDescription, "", ::openManual),
SITE("Open website", Category.OPEN, openDescription, "", ::openSite),
SOURCE("Open app source", Category.OPEN, openDescription, "", ::openSource),
NEXUS("Open app nexus page", Category.OPEN, openDescription, "", ::openNexus),
PURGE("Purge all sym links", Category.DEPLOY, purgeDescription, purgeUsage, ::purge),
MOD("Update a mod", Category.EDIT, changeHelp, changeDescription, ::changeMod),
PROFILE("Create and use local mod lists", Category.DEPLOY, profileDescription, profileUsage, ::profile),
Expand Down
14 changes: 11 additions & 3 deletions src/main/kotlin/commands/OpenMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ fun openAppDataPath(args: List<String>) = open(toolConfig.appDataPath!!, "appdat
fun openIniPath(args: List<String>) = open(toolConfig.iniPath!!, "ini path", args.contains("cli"))
fun openPluginsTxt(args: List<String>) = open(toolConfig.appDataPath!! +"/Plugins.txt", "plugins file", args.contains("cli"))
fun openJarPath(args: List<String>) = open(".", "jar path", args.contains("cli"))
fun openManual(args: List<String>) = openInWeb("https://manapart.github.io/starfield-mod-manager-site/manual.html")
fun openSite(args: List<String>) = openInWeb("https://manapart.github.io/starfield-mod-manager-site/index.html")
fun openSource(args: List<String>) = openInWeb("https://github.com/ManApart/starfield-mod-manager")
fun openNexus(args: List<String>) = openInWeb("https://www.nexusmods.com/starfield/mods/6576")

private fun openMod(web: Boolean = true, args: List<String>) {
val cli = args.contains("cli")
Expand All @@ -40,12 +44,16 @@ fun openInWeb(mod: Mod) {
if (mod.id == null) {
println("Can't open ${mod.name} because it doesn't have an id.")
} else {
openInWeb(mod.url(), mod.name)
}
}

fun openInWeb(url: String, urlName: String = url) {
try {
Desktop.getDesktop().browse(URI(mod.url()))
Desktop.getDesktop().browse(URI(url))
} catch (e: Exception) {
println("Unable to open ${mod.name} in web")
println("Unable to open $urlName in web")
}
}
}

fun openLocal(mod: Mod, cli: Boolean) = open(mod.filePath, mod.name, cli)
Expand Down

0 comments on commit a187a42

Please sign in to comment.