Skip to content

Commit

Permalink
Solve idea resolution when toolbox is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
pgreze committed Mar 7, 2023
1 parent 7b305b1 commit 8cc3c9d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/github/pgreze/aidea/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fun main(args: Array<String>) {

class App : CliktCommand(
help = """
idea alternative supporting a multi-installation setup
IntelliJ provided idea shell script alternative supporting a multi-installation setup
(like Jetbrains Toolbox but in your shell).
Without any argument, displays all the found installations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private fun List<IdeaInstall>.displayChoiceHeaders() {
private fun selectInstallIndex(size: Int): Int? {
while (true) {
print("Which installation to use? ")
return (readLine() ?: return null) // ctrl+d
return (readlnOrNull() ?: return null) // ctrl+d
.toIntOrNull()
?.takeIf { it - 1 in 0 until size }
?: continue
Expand Down
31 changes: 15 additions & 16 deletions app/src/main/kotlin/com/github/pgreze/aidea/app/OpenMainKts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ fun File.generateMainKtsProject(): File =
resolveMainKtsProject()
.apply {
require(deleteRecursively()) {
throw IOException("Could not delete $this")
throw IOException("Could not delete everything in $this")
}
mkdirs()
resolve("build.gradle.kts")
.writeText(BUILD_GRADLE_KTS)
resolve("settings.gradle")
.writeText("rootProject.name = \"${name}\"")

resolve("build.gradle.kts").writeText(BUILD_GRADLE_KTS)

resolve("settings.gradle").writeText("rootProject.name = \"${name}\"")

resolve("src").let { srcDir ->
srcDir.mkdir()
Expand All @@ -30,16 +30,15 @@ fun File.generateMainKtsProject(): File =
}
}

private val BUILD_GRADLE_KTS = """
plugins {
kotlin("jvm") version "1.7.10"
}
private const val BUILD_GRADLE_KTS = """plugins {
kotlin("jvm") version "1.7.10"
}
repositories {
mavenCentral { content { includeGroupByRegex("org.jetbrains(|.kotlin)") } }
}
repositories {
mavenCentral { content { includeGroupByRegex("org.jetbrains(|.kotlin)") } }
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
""".trimIndent()
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
"""
5 changes: 0 additions & 5 deletions idea/src/main/kotlin/com/github/pgreze/aidea/idea/Idea.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ fun listIdeaInstallations(): Sequence<IdeaInstall> = sequence {
private fun File.resolveToolboxLaunchers(
ideaType: IdeaType
): Sequence<IdeaInstall> = sequence {
if (isDirectory.not()) {
throw IllegalArgumentException("Invalid toolbox directory $this")
}

// TODO: improve this part
listFiles()?.forEach f1@{ f1 -> // ch-0
if (f1.isDirectory.not()) return@f1
f1.listFiles()?.forEach f2@{ f2 -> // 202.7660.26
Expand Down

0 comments on commit 8cc3c9d

Please sign in to comment.