console-command-manager
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Console command manager

Build Status Coverage Status

NPM NPM

It run custom bash commands, is able to control your service from console like the think client does.

Be free and ask me questions personally on Gitter

// import { runCommand, extractValue } from 'console-command-manager' // @todo Uncomment at the real case.
import { runCommand, extractValue } from '../src/index'

(async function () {
  await runCommand(
    [
      {
        name: 'print',
        title: 'Prints values',
        handler: async ({request, injection: {console, DateFactory}}) => {
          const format = extractValue(request.args, 'format', 'not_set')
          console.log(`I am printing you text  ' ${request.values.join(' ')}  at ${new DateFactory()} ' format - ${format}`)
        }
      },
    ],
    {
      DateFactory: Date
    },
    process.argv.slice(2)
  )
})()

The command line

npx babel-node ./example/commander.js print --format="A4" some text

Produces such lines

I am printing you text  ' some text  at Fri Mar 20 2020 18:11:19 GMT+0200 (Eastern European Standard Time) ' format - A4

For the full documentation read WIKI

Main parts of the project:

It manages commands, uses own string parser that can be used independently. Command handler could be asynchronous. The code written by the library have to be testable.

Package Sidebar

Install

npm i console-command-manager

Weekly Downloads

8

Version

0.1.2

License

ISC

Unpacked Size

14.4 kB

Total Files

8

Last publish

Collaborators

  • victor-shelepen