Router property configuration
The router
property is an object which provide low level access to modify the behaviour of the router plugin. Learn more about routing in the usage documentation.
promise
(boolean,false
)
Wrap all the returned value into a promise if not yet one.handler
(function|string)
The function or the module name used to handle errors or undefined handlers.stdin
(stream.Readable
,process.stdin
)
The standard input stream reader. It default toprocess.stdin
but it is sometime usefull to switch your own implementation such as in your tests.stdout
(stream.Writable
,process.stdout
)
The standart output stream writer. It default toprocess.stdout
but it is sometime usefull to switch your own implementation such as in your tests. Also, thegrpc_server
plugin switch its own writer used to communicate with the GRPC the server.stdout_end
(boolean,false
)
Close the standart output stream writer when the command has been processed.stderr
(stream.Writable
,process.stderr
)
The standart error stream writer. It default toprocess.stderr
. The same argument as withstdout
apply. Note, thehelp
plugin write tostderr
by default.stderr_end
(boolean,false
)
Close the standart output stream writer when the command has been processed.
Short declaration
If the router
property is a string, it is interpreted as the module name exporting the handler function. For example:
const shell = require('shell')
shell({
router: './my/module'
})
Is equivalent to:
const shell = require('shell')
shell({
router: {
handler: './my/module'
}})
Note, the help
command, activated by default when a first command is registered, writes by default to stderr
and close the stream if stderr_end
is enabled.