interactive-cli
Advanced tools
Comparing version 1.1.1 to 1.1.2
23
index.js
@@ -5,3 +5,22 @@ const _ = require('lodash') | ||
const numberToLetters = i => { | ||
if (i >= ALPHABET.length) { | ||
const firstLetter = Math.floor(i / ALPHABET.length) | ||
const secondLetter = i - ALPHABET.length * firstLetter | ||
return `${ALPHABET[firstLetter]}${ALPHABET[secondLetter]}` | ||
} | ||
return ALPHABET[i] | ||
} | ||
const lettersToNumber = letters => { | ||
if (letters.length === 2) { | ||
const firstLetter = ALPHABET.indexOf(letters[0]) | ||
const secondLetter = ALPHABET.indexOf(letters[1]) | ||
return firstLetter * ALPHABET.length + secondLetter | ||
} else if (letters.length === 1) { | ||
return ALPHABET.indexOf(letters[0]) | ||
} | ||
} | ||
// Error that should be thrown to exit to the start of the application | ||
@@ -85,3 +104,3 @@ function DontContinue(message) { | ||
optionKeys.forEach((optionKey, i) => { | ||
console.log(`${ALPHABET[i]}) ${options[optionKey]}`) | ||
console.log(`${numberToLetters(i)}) ${options[optionKey]}`) | ||
}) | ||
@@ -97,3 +116,3 @@ console.log("q) Quit") | ||
let selectedOption | ||
const i = ALPHABET.indexOf(res) | ||
const i = lettersToNumber(res) | ||
@@ -100,0 +119,0 @@ // Only return null if defaultOptionText was specified |
{ | ||
"name": "interactive-cli", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Making it easy to create interactive command line scripts in Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
317
13313
4