entero

1.3.3 • Public • Published

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

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

Package Sidebar

Install

npm i entero

Weekly Downloads

0

Version

1.3.3

License

ISC

Unpacked Size

6.11 kB

Total Files

4

Last publish

Collaborators

  • sergueyarellano