demo-cli
is a simple javascript class that allows you to create neat-o canned demos of CLI-based tools.
import DemoCLI from "./demo-cli.js" const cli = new DemoCLI("#simple") const h = (async () => { cli.printPrompt() await cli.type('echo "testing this"') cli.enterKey() cli.println("testing this") cli.printPrompt() })()
import DemoCLI from "./demo-cli.js" const cli = new DemoCLI("#cli") cli.printPrompt() cli.print("print ") cli.print("on same line ") cli.enterKey() let colorNum = 1 for(let x = 0; x <= 16; x++) { cli.printPrompt() cli.println("colors", {className: `base0${x.toString(16)}`}) colorNum++ } cli.println("println") cli.println("println") cli.printPrompt({className: "base08"})
import DemoCLI from "./demo-cli.js" const t = new DemoCLI("#typing-cli") const f = (async () => { while (true) { t.printPrompt() await t.type("here I am typing", {delay: 60, random: true}) t.enterKey() t.printPrompt() await t.wait(2000) await t.type("here I am typing more stuff") t.enterKey() t.printPrompt() await t.type("going to reset here") await t.wait(2000) t.enterKey() t.reset() } })()