console-command-manager
v0.1.2
Published
Console command manager. It helps run custom commands from bash, can control your service from the console as the thin client does. String parser command manager and console runner are main parts of the project.
Downloads
3
Maintainers
Readme
Console command manager
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.