JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 37
  • Score
    100M100P100Q36623F
  • License MIT

simple lightweight non-invasive CLI shell with history and autocompletion

Package Exports

  • tpmorp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tpmorp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

#tpmorp A simple immersive CLI interface helper

##Why? Because other modules are way too over complicated. tpmorp has no exernal dependencies and uses just the functionality available in Nodes core readline module.

##How

$ npm install --save tpmorp
var readline = require('readline')
var morp = require('tpmorp')(readline)

##Example The example code shows how to use tpmorp in a simple hello/goodbye CLI interface. See example.js

'use strict'

var readline = require('readline')
var morp = require('tpmorp')(readline)

function hello (args, cb) {
  console.log('hello ' + args)
  cb(false)
}

function goodbye (args, cb) {
  console.log('goodbye ' + args)
  cb(true)
}

var commands = {
  hello: {sub: ['all', 'peter', 'matteo'],
    action: hello,
    description: 'say hello'},

  goodbye: {sub: ['all', 'peter', 'dave'],
    action: goodbye,
    description: 'say goodbye'}
}

morp.start('test>', commands, function (err, command, args) {
  if (err) {
    console.log(err)
    morp.displayPrompt()
  } else {
    command.action(args, function (quit) {
      if (quit) {
        morp.stop()
      } else {
        morp.displayPrompt()
      }
    })
  }
})

morp.displayPrompt()

#License MIT, knock yourself out...