Mercurial > cgi-bin > hgweb.cgi > PassMan
comparison src/main/kotlin/name/blackcap/passman/Main.kt @ 28:287eadf5ab30 default tip
Check for timeouts inside subcommands while in interactive mode as well.
author | David Barts <n5jrn@me.com> |
---|---|
date | Wed, 31 Jul 2024 11:21:18 -0700 |
parents | 3a3067ba673b |
children |
comparison
equal
deleted
inserted
replaced
27:3a3067ba673b | 28:287eadf5ab30 |
---|---|
76 if (subcommand in DISALLOWED) { | 76 if (subcommand in DISALLOWED) { |
77 error("$subcommand subcommand not allowed in interactive mode") | 77 error("$subcommand subcommand not allowed in interactive mode") |
78 lastStatus = 2 | 78 lastStatus = 2 |
79 continue | 79 continue |
80 } | 80 } |
81 val beforeRun = System.currentTimeMillis() | |
81 try { | 82 try { |
82 runSubcommand(subcommand, scArgs) | 83 runSubcommand(subcommand, scArgs) |
83 lastStatus = 0 | 84 lastStatus = 0 |
84 } catch(e: SubcommandException) { | 85 } catch(e: SubcommandException) { |
85 handleSubcommandException(e) | 86 handleSubcommandException(e) |
86 lastStatus = e.status | 87 lastStatus = e.status |
87 } catch(e: MessagedException) { | 88 } catch(e: MessagedException) { |
88 handleMessagedException(e) | 89 handleMessagedException(e) |
89 lastStatus = 1 | 90 lastStatus = 1 |
91 } | |
92 if (System.currentTimeMillis() - beforeRun > MAX_TIME_MILLIS) { | |
93 error("time limit exceeded, goodbye!") | |
94 lastStatus = 1 | |
95 break | |
90 } | 96 } |
91 } | 97 } |
92 exitProcess(lastStatus) | 98 exitProcess(lastStatus) |
93 } | 99 } |
94 | 100 |