Skip to content

Commit f29db6a

Browse files
committed
Allow setup to optionally override your existing config
Good for cases where someone already used MIO before but is now getting a new installation.
1 parent 0264651 commit f29db6a

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

build.gradle.kts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,29 @@ tasks.register<Copy>("setup") {
106106
// Setup configuration file.
107107
val file = File("${System.getenv("HOME")}/.mio/debugger.properties")
108108
if (!file.exists()) {
109-
file.parentFile.mkdirs()
110-
println("Generating a default configuration file ${file.absolutePath}")
111-
val properties = Properties()
112-
properties.setProperty("wdcli", wdcliPath)
113-
properties.setProperty("wdcli-symbolic", wdcliSymbolicPath)
114-
properties.setProperty("concolic", "true")
115-
properties.store(file.writer(), null)
109+
writeDefaultConfig(file)
110+
} else {
111+
println("Config already exists, do you want to overwrite it? y/n")
112+
var answer = readln()
113+
while (answer != "y" && answer != "n") {
114+
answer = readln()
115+
println("Please enter y or n")
116+
}
117+
if (answer == "y") {
118+
writeDefaultConfig(file)
119+
}
120+
else {
121+
println("Keeping existing config $file")
122+
}
116123
}
117124
}
125+
126+
fun writeDefaultConfig(file: File) {
127+
file.parentFile.mkdirs()
128+
println("Generating a default configuration file ${file.absolutePath}")
129+
val properties = Properties()
130+
properties.setProperty("wdcli", wdcliPath)
131+
properties.setProperty("wdcli-symbolic", wdcliSymbolicPath)
132+
properties.setProperty("concolic", "true")
133+
properties.store(file.writer(), null)
134+
}

0 commit comments

Comments
 (0)