diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2020-01-05 21:04:27 -0800 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2020-01-05 21:04:27 -0800 |
commit | c023583d01fabb44c7aae72b5908ccfcf7fe0c01 (patch) | |
tree | bf6c68fd87fdb66db1389ccd00ba3f228e0e7664 /src | |
parent | edf8dc1c042edd126f74e6bc3669bbc52d20d375 (diff) |
timestamp for repl
Diffstat (limited to 'src')
-rw-r--r-- | src/server/Session/session.ts | 2 | ||||
-rw-r--r-- | src/server/repl.ts | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/server/Session/session.ts b/src/server/Session/session.ts index c9b49cc73..d07bd13a2 100644 --- a/src/server/Session/session.ts +++ b/src/server/Session/session.ts @@ -270,7 +270,7 @@ export namespace Session { }); // builds the repl that allows the following commands to be typed into stdin of the master thread - const repl = new Repl({ identifier: masterIdentifier }); + const repl = new Repl({ identifier: () => `${timestamp()} ${masterIdentifier}` }); repl.registerCommand("exit", [], () => execSync(onWindows ? "taskkill /f /im node.exe" : "killall -9 node")); repl.registerCommand("restart", [], restart); repl.registerCommand("set", [/[a-zA-Z]+/g, "port", /\d+/g, /true|false/g], args => { diff --git a/src/server/repl.ts b/src/server/repl.ts index b77fbcefc..bd00e48cd 100644 --- a/src/server/repl.ts +++ b/src/server/repl.ts @@ -2,7 +2,7 @@ import { createInterface, Interface } from "readline"; import { red, green, white } from "colors"; export interface Configuration { - identifier: string; + identifier: () => string | string; onInvalid?: (culprit?: string) => string | string; onValid?: (success?: string) => string | string; isCaseSensitive?: boolean; @@ -15,7 +15,7 @@ export interface Registration { } export default class Repl { - private identifier: string; + private identifier: () => string | string; private onInvalid: (culprit?: string) => string | string; private onValid: (success: string) => string | string; private isCaseSensitive: boolean; @@ -32,6 +32,8 @@ export default class Repl { this.interface = createInterface(process.stdin, process.stdout).on('line', this.considerInput); } + private resolvedIdentifier = () => typeof this.identifier === "string" ? this.identifier : this.identifier(); + private usage = () => { const resolved = this.keys; if (resolved) { @@ -43,10 +45,10 @@ export default class Repl { while (!(next = keys.next()).done) { members.push(next.value); } - return `${this.identifier} commands: { ${members.sort().join(", ")} }`; + return `${this.resolvedIdentifier()} commands: { ${members.sort().join(", ")} }`; } - private success = (command: string) => `${this.identifier} completed execution of ${white(command)}`; + private success = (command: string) => `${this.resolvedIdentifier()} completed execution of ${white(command)}`; public registerCommand = (basename: string, argPatterns: (RegExp | string)[], action: ReplAction) => { const existing = this.commandMap.get(basename); |