Skip to content

Commit c9cc6b9

Browse files
committed
Make quitting require 'Q' to prevent accidents
Closes #9
1 parent 8e08fd4 commit c9cc6b9

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/main/kotlin/org/strykeforce/thirdcoast/Readers.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ fun LineReader.readMenu(size: Int, prompt: String, default: String = "", quit: B
8080
else -> INVALID
8181
}
8282
} catch (nfe: NumberFormatException) {
83-
when (line.toLowerCase()) {
84-
"b" -> BACK
85-
"q" -> if (quit) QUIT else INVALID
83+
when (line) {
84+
"b", "B" -> BACK
85+
"Q" -> if (quit) QUIT else INVALID
8686
else -> INVALID
8787
}
8888
}
@@ -108,7 +108,7 @@ fun Terminal.readRawMenu(size: Int, prompt: String, quit: Boolean = false): Int
108108
this.writer().println()
109109
return when (char) {
110110
'b', 'B', '\r' -> BACK
111-
'q', 'Q' -> if (quit) QUIT else INVALID
111+
'Q' -> if (quit) QUIT else INVALID
112112
else -> validMenuChoices.indexOf(char) // -1 == INVALID
113113
}
114114
}

src/main/kotlin/org/strykeforce/thirdcoast/command/MenuCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MenuCommand(
3838
}
3939
if (parent != null)
4040
writer.println("back to previous menu".toMenu("b"))
41-
writer.println("quit TCT".toMenu("q"))
41+
writer.println("quit TCT".toMenu("Q"))
4242

4343
}
4444

src/test/kotlin/org/strykeforce/thirdcoast/ReadersTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ internal class ReadersTest {
168168

169169
@Test
170170
fun `gets quit`() {
171-
whenever(reader.readLine(any(), isNull(), any())).thenReturn("q")
171+
whenever(reader.readLine(any(), isNull(), any())).thenReturn("Q")
172172
assertThat(reader.readMenu(menu)).isEqualTo(QUIT)
173173
}
174174

0 commit comments

Comments
 (0)