mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-27 05:03:27 -08:00
Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment. This change fixes that.
This commit is contained in:
35
84_Super_Star_Trek/javascript/cli.mjs
Normal file
35
84_Super_Star_Trek/javascript/cli.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
onExit,
|
||||
onPrint,
|
||||
onInput,
|
||||
setGameOptions,
|
||||
getGameState,
|
||||
gameMain,
|
||||
} from "./superstartrek.mjs";
|
||||
|
||||
import util from "util";
|
||||
import readline from "readline";
|
||||
|
||||
onExit(function exit() {
|
||||
process.exit();
|
||||
});
|
||||
|
||||
onPrint(function print(...messages) {
|
||||
console.log(messages.join(""));
|
||||
});
|
||||
|
||||
onInput(async function input(prompt) {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
terminal: false,
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
rl.question(`${prompt}? `, (response) => {
|
||||
rl.close();
|
||||
resolve(response);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gameMain().then(process.exit).catch(console.log);
|
||||
Reference in New Issue
Block a user