console-gui
v1.0.1
Published
A library for making interactive command line apps in node
Downloads
3
Maintainers
Readme
ConsoleGUI
Install:
npm install console-gui
Usage:
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:
string
The name to usereturns
ConsoleGUI Object
app.name("bar");
.version(string)
Sets the version of the program or app:
string
The version to usereturns
ConsoleGUI Object
app.version("1.2.3");
.motd(string)
Sets the welcome message:
string
The message to usereturns
ConsoleGUI 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.
string
The string of the logofunction
A function with a callbackreturns
ConsoleGUI 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:
string
Command to be addedreturns
Command Object
app.addCommand("foo");
Command Methods:
.description(string)
Sets the description of the command
string
The description of the commandreturns
Command Object
app.addCommand("foo")
.description("bar")
.action(function)
function
The function that will run when the command is executedreturns
Command Object
app.addCommand("foo <arg>")
.action(arg => {
console.log(arg);
})