Mercurial > cgi-bin > hgweb.cgi > PassMan
changeset 27:3a3067ba673b
Add idle-time detection to interactive mode, clean up imports.
author | David Barts <n5jrn@me.com> |
---|---|
date | Sat, 27 Jul 2024 09:50:54 -0700 |
parents | 69526ae8c8de |
children | 287eadf5ab30 |
files | src/main/kotlin/name/blackcap/passman/Arguments.kt src/main/kotlin/name/blackcap/passman/Entry.kt src/main/kotlin/name/blackcap/passman/Main.kt |
diffstat | 3 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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(
--- 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
--- 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<String>) { @@ -47,14 +42,21 @@ fun runInteractive() { val DISALLOWED = setOf<String>("password") val QUIT = setOf<String>("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) {