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
(async function () {
// const { runCommand } = require('console-command-manager') // @todo Uncomment at the real case.
const { runCommand, extractValue } = require('../src/index')
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}`)
return true
}
},
],
{
DateFactory: Date
},
process.argv.slice(2)
)
})()
The command line
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.