Skip to content

Commit

Permalink
Improve defaults of the search command
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkmar committed Jun 26, 2021
1 parent 6c7cba1 commit 02b7d03
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/kotlin/net/axay/pacmc/commands/Search.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,23 @@ object Search : CliktCommand(
) {
private val searchTerm by argument()
private val gameVersion by option("-g", "--game-version", help = "Set a specific game version (latest by default)")
private val allVersions by option("-i", "--all-versions", help = "Whether to show mods for all Minecraft versions").flag()
private val supressUnavailable by option("-s", "--supress-unavailable", help = "Whether to supress mods which are not available for the given Minecraft version").flag()
private val allResults by option("-a", "--all", help = "Whether to show all results without any limit").flag()
private val limit by option("-l", "--limit", help = "The amount of results (defaults to 15)").int().default(15)

override fun run() = runBlocking(Dispatchers.Default) {
val versionRequest = async {
when {
gameVersion != null -> gameVersion
allVersions -> null
else -> CurseProxy.getMinecraftVersions().first().versionString
}
}
CurseProxy.search(
searchTerm,
null,
if (supressUnavailable) versionRequest.await() else null,
if (!allResults) limit else null
).forEach {
terminal.printProject(it, versionRequest.await(), allVersions)
terminal.printProject(it, versionRequest.await(), !supressUnavailable)
}
}
}

0 comments on commit 02b7d03

Please sign in to comment.