1.1.3 • Published 1 year ago

easy-terminal v1.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Easy terminal

An easy to use web terminal without any dependency and minified.

Demo

Installation

npm i easy-terminal

Usage

see the example folder for a complete case.

import { EasyTerminal } from './node_modules/easy-terminal/index.js';
const terminalElement = window.document.getElementById('terminal'); // div where you want the terminal
new EasyTerminal({
    elementHtml: terminalElement,
    window: { show: true, title: 'EasyTerminal' },
    nativeCommands: true,
    welcome: 'Welcome to EasyTerminal',
    history: true,
    noEmptyCommand: true,
    customCommands: [
        {
            name: 'test',
            help: 'test command',
            method: async function (cmd) {
                return await cmd.select(objTest, true)
            }
        },
        {
            name: 'test2',
            help: 'test2 command',
            method: async function (cmd) {
                return await cmd.select(stringsTest, false)
            }
        },
        {
            name: 'askAge',
            help: 'ask age to user',
            method: async function (cmd) {
                const age = await cmd.ask('age ?', true);
                cmd.echo('Age: ' + age);
            }
        }
    ]
});

Config

Terminal Config

nametypedefaultdesc
windowObjectN/ASome style for the termianal
welcomeStringnullWelcome message (first line)
elementHtmlHTMLElementnulldiv where you want the terminal
data-psstring$Char before command input
historybooleanfalseIf yes you can access history with arrow up and down
noEmptyCommandbooleanfalseIf true cancel empty command
nativeCommandsbooleanfalseNative commands are help and clear
customCommandsITerminalCommandN/APass you're commands here

Window interface

nametypedefaultdesc
showbooleanfalseShow a window
titlestring'EasyTerminal'Title of the window
bgColorstring#198754Background color
textColorstringwhiteText color

ITerminalCommand interface

nametyperequireddesc
namestringtrueCommand name
methodfunctiontruefunction called
helpstringtrueText show on help command

License

ISC

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago