pseudoterminal
v0.0.4
Published
a toy terminal
Downloads
2
Readme
pseudoTerminal
a toy terminal
install
<script src="path/to/pseudoterminal.umd.js"></script>
usage
Terminal = PseudoTerminal(<wrappid>, [option]);
Terminal
.addCommand(<cmdName>, <cmdBody>)
.addCommand(<cmdName1>, <cmdBody>)
.destroy(); // destroy the terminal
doc
option
{Object}option.width
{String} (css width)option.height
{String} (css height)bgColor
background color(css color str)option.promptSign
{String}fontFamily
{String}fontSize
{String}
addCommand
{Function}cmdName
{String} command namecmdBody
{Object}cmdBody.handler
{Function}cmdBody.shortopts
{String} option letters that the command wants to recognize (i.e., the same format that Unix getopt() uses)
cmdBody.handler(util[, param])
{Function}- if
cmdBody.shortopts
is leave out, thenhandler
only got one paramutil
- if
cmdBody.shortopts
is set, thenhandler
got two paramsparam
andutil
- use
uitl.output(result)
to printresult
on terminal - use
util.next()
to handle next command - use
util.loading(true)
to show spinner - use
util.loading(false)
to hide spinner
- if
exapmles
const Terminal = PseudoTerminal('cmd_wrapper', {
bgColor: 'rgba(0, 0, 0, .8)',
color: '#fff',
promptSign: '$'
});
Terminal.addCommand('hello', {
shortopts: "a:b",
handler: function(util, param) {
// param => {a: <value>, b: true}
util.output("hello", param.a)
util.next();
}
})