m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/dicebag.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/bin/dicebag.js b/bin/dicebag.js
index f7b0921..6e88ae6 100755
--- a/bin/dicebag.js
+++ b/bin/dicebag.js
@@ -24,7 +24,7 @@ const parseArgs = () => {
const rollDie = (string, roller) => {
try {
- const die = parse(string.trim())
+ const die = parse(string)
console.log(roller(die))
} catch (error) {
console.log(error.message)
@@ -32,8 +32,14 @@ const rollDie = (string, roller) => {
}
const runIoLoop = (roller) => {
+ console.log("Type 'quit' or 'exit' to exit")
process.stdin.setEncoding('utf8')
process.stdin.on('data', (string) => {
+ string = string.trim()
+ if (string === 'exit' || string === 'quit') {
+ process.exit(0)
+ }
+
rollDie(string, roller)
})
}