Mercurial > cgi-bin > hgweb.cgi > PassMan
comparison src/main/kotlin/name/blackcap/passman/Main.kt @ 23:af86b8e0b88c
Clean up exit output.
author | David Barts <n5jrn@me.com> |
---|---|
date | Tue, 02 Jul 2024 18:18:29 -0700 |
parents | 07406c4af4a5 |
children | 2188b2f13326 |
comparison
equal
deleted
inserted
replaced
22:07406c4af4a5 | 23:af86b8e0b88c |
---|---|
47 fun runInteractive() { | 47 fun runInteractive() { |
48 val DISALLOWED = setOf<String>("password") | 48 val DISALLOWED = setOf<String>("password") |
49 val QUIT = setOf<String>("exit", "quit") | 49 val QUIT = setOf<String>("exit", "quit") |
50 var lastStatus = 0 | 50 var lastStatus = 0 |
51 while (true) { | 51 while (true) { |
52 val rawLine = System.console()?.readLine("passman> ") ?: break | 52 val rawLine = System.console()?.readLine("passman> ") |
53 if (rawLine == null) { | |
54 println() // ensure shell prompt comes out on a line of its own | |
55 break | |
56 } | |
53 val s = Shplitter() | 57 val s = Shplitter() |
54 s.feed(rawLine) | 58 s.feed(rawLine) |
55 if (!s.complete) { | 59 if (!s.complete) { |
56 error("unterminated quoting") | 60 error("unterminated quoting") |
57 lastStatus = 1 | 61 lastStatus = 1 |
80 } catch(e: MessagedException) { | 84 } catch(e: MessagedException) { |
81 handleMessagedException(e) | 85 handleMessagedException(e) |
82 lastStatus = 1 | 86 lastStatus = 1 |
83 } | 87 } |
84 } | 88 } |
85 println() // ensure shell prompt comes out on a line of its own | |
86 exitProcess(lastStatus) | 89 exitProcess(lastStatus) |
87 } | 90 } |
88 | 91 |
89 fun runSubcommand(name: String, args: Array<String>): Unit { | 92 fun runSubcommand(name: String, args: Array<String>): Unit { |
90 val instance = getInstanceForClass(getClassForSubcommand(name)) | 93 val instance = getInstanceForClass(getClassForSubcommand(name)) |