1.0.1 • Published 6 years ago
console-gui v1.0.1
ConsoleGUI
Install:
npm install console-guiUsage:
const ConsoleGUI = require("console-gui");
const app = new ConsoleGUI();
app.name("foo")
.version("1.0.0")
.motd("Welcome message!")
.logo(" <= FOO => ");
app.run();Examples:
app
.name("TESTING")
.version("1.101.2")
.motd("Message Of The Day!")
app.addCommand("hello")
.action(() => {
console.log("world")
})
app.addCommand("say <message>")
.description("Say something to the world!")
.action(messages => {
console.log(messages);
})
app.run();ConsoleGUI Methods:
.name(string)
Sets the name for the program or app:
stringThe name to usereturnsConsoleGUI Object
app.name("bar");.version(string)
Sets the version of the program or app:
stringThe version to usereturnsConsoleGUI Object
app.version("1.2.3");.motd(string)
Sets the welcome message:
stringThe message to usereturnsConsoleGUI Object
app.motd("Welcome message!");.logo(string|function)
Sets the logo for the program or app. If it's a string, just the string will be printed, but if it's a function, the function will be executed and when the callback is called the program or app will then start.
stringThe string of the logofunctionA function with a callbackreturnsConsoleGUI Object
app.logo(" <= FOO => ");
app.logo(callback => {
// Print your logo or do something...
callback();
}).run()
Start the app or program
app.run();.addCommand(string)
Add a command to your app:
stringCommand to be addedreturnsCommand Object
app.addCommand("foo");Command Methods:
.description(string)
Sets the description of the command
stringThe description of the commandreturnsCommand Object
app.addCommand("foo")
.description("bar").action(function)
functionThe function that will run when the command is executedreturnsCommand Object
app.addCommand("foo <arg>")
.action(arg => {
console.log(arg);
})