1.3.3 • Published 4 years ago

entero v1.3.3

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

entero

A tiny CLI that leaves the prompt at the bottom.

Usage

index.js

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?')
  }
})


// Testing
let count = 0
setInterval(() => { console.log('count increased:', count++) }, 1000)
$ node index.js

npm.io

templates

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' }) //  max estrella  **cyan**
cli.log('encrypt', { msg: 'secrets!' }) // 115*101*99*114*101*116*115*33

You can mix it with packages like chalk

Completions

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')
1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago