A tiny CLI that leaves the prompt at the bottom.
const entero = require('entero')
entero({
prompt: '> ',
onLine: (line) => console.log(new Date().toLocaleTimeString(), '💬', line),
commands: {
help: () => console.log('on my way! \n(っ▀¯▀)つ'),
display: (...args) => console.log('args passed:', ...args),
point: () => console.log('oh, what is the point?')
}
})
let count = 0
setInterval(() => { console.log('count increased:', count++) }, 1000)
const cli = entero({
prompt: '> ',
onLine: console.log,
templates: {
highlightnick: ({ nickname }) => `\x1b[36m${nickname}\x1b[0m`,
encrypt: ({ msg }) => [].map.apply(msg, [(s) => s.charCodeAt()]).join('*')
}
})
cli.log('highlightnick', { nickname: 'max estrella' })
cli.log('encrypt', { msg: 'secrets!' })
When passing commands, completions are set automatically, but more completions can be set up once instantiated. Pressing tab will trigger completions if a match occurs.
cli.setCompletion('@home')
cli.setCompletion('#tag')
cli.setCompletion('.foo')