# HG changeset patch # User David Barts # Date 1722099054 25200 # Node ID 3a3067ba673ba110bce45c9832d3f5af54a2f436 # Parent 69526ae8c8de92ab36b5b6c9ae89fe52682c379c Add idle-time detection to interactive mode, clean up imports. diff -r 69526ae8c8de -r 3a3067ba673b src/main/kotlin/name/blackcap/passman/Arguments.kt --- a/src/main/kotlin/name/blackcap/passman/Arguments.kt Fri Jul 05 10:11:31 2024 -0700 +++ b/src/main/kotlin/name/blackcap/passman/Arguments.kt Sat Jul 27 09:50:54 2024 -0700 @@ -7,7 +7,6 @@ import kotlin.reflect.full.hasAnnotation import kotlin.reflect.full.isSubtypeOf import kotlin.reflect.typeOf -import kotlin.system.exitProcess @Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY) annotation class Argument( diff -r 69526ae8c8de -r 3a3067ba673b src/main/kotlin/name/blackcap/passman/Entry.kt --- a/src/main/kotlin/name/blackcap/passman/Entry.kt Fri Jul 05 10:11:31 2024 -0700 +++ b/src/main/kotlin/name/blackcap/passman/Entry.kt Sat Jul 27 09:50:54 2024 -0700 @@ -1,6 +1,5 @@ package name.blackcap.passman -import java.sql.ResultSet import java.util.* import kotlin.reflect.KProperty import kotlin.reflect.full.declaredMemberProperties diff -r 69526ae8c8de -r 3a3067ba673b src/main/kotlin/name/blackcap/passman/Main.kt --- a/src/main/kotlin/name/blackcap/passman/Main.kt Fri Jul 05 10:11:31 2024 -0700 +++ b/src/main/kotlin/name/blackcap/passman/Main.kt Sat Jul 27 09:50:54 2024 -0700 @@ -1,11 +1,6 @@ package name.blackcap.passman -import java.io.BufferedReader -import java.io.InputStreamReader import java.util.* -import java.util.stream.Collectors -import kotlin.reflect.jvm.javaMethod -import kotlin.reflect.jvm.kotlinFunction import kotlin.system.exitProcess fun main(args: Array) { @@ -47,14 +42,21 @@ fun runInteractive() { val DISALLOWED = setOf("password") val QUIT = setOf("exit", "quit") + val MAX_TIME_MILLIS = 10L * 60L * 1000L var lastStatus = 0 println("This is PassMan interactive mode. Type help for help.") while (true) { + val beforeRead = System.currentTimeMillis() val rawLine = System.console()?.readLine("passman> ") if (rawLine == null) { println() // ensure shell prompt comes out on a line of its own break } + if (System.currentTimeMillis() - beforeRead > MAX_TIME_MILLIS) { + error("time limit exceeded, goodbye!") + lastStatus = 1 + break + } val s = Shplitter() s.feed(rawLine) if (!s.complete) {