CLI-GUI - but much better. Graphical interface in command line.
- List
- Checklist
- Search
- Table
- Prompt
- Guided prompt
- Log
- Terminal
- Box
- Editor
npm install cligui2
varCliGui=require('cligui2');varinterface=newCliGui();This stops the interface completely
Used to remove "layers".
Resets interface
Arguments: target,function
Adds a listener to a target
Available targets:
- key - Key presses
Arguments: target,function
Removes a listener from a target
Arguments: target
clears listeners from a target
Arguments: title,items,call
The list function is very flexible. It can be called in four different ways.
- Options argument as an array of strings, call argument a function
- Options argument as an array of strings, call argument as an array of functions
- Options argument as an array of objects
- Options argument as an object
Example:
interface.list("This is a list",["a","b","c","d"],function(main,chosen){})interface.list("Another way",["a","b","c"],[function(main){},function(main){},function(main){}])interface.list("Again Another way",[{name: "a",call: function(main){}},{name: "b",call: function(main){}}])interface.list("The fourth way",{a: function(main){},b: function(main){},c: function(main){}})Arguments: title,items,call
The checklist function is also as flexible as the list function. For usage, please refer to the list documentation. A option can also be checked on by default. To do so please set checked to true.
Example:
interface.checklist("A is checked on by default",[{name: "a",checked: true,call: function(main){}},{name: "b",call: function(main){}}])Arguments: title,items,call
Usage is same as the usage for the List function
Arguments: title,data
Data is an object
Example:
interface.table("This is a table",{thead: ["a","b","c"],// this is the sticky at the topdata: [["hello","this","is"],["a","cool","test"],["tables","are","fun"],// the contents of the tablesizes: [8,8,8],// optional: Sets the size for each columncall: function(main,chosen){// the callback}})Arguments: title,shadow,call
The prompt funcion prompts the user for a text input.
Example:
interface.prompt("this is a prompt","type something",function(main,output){})The guided prompt function allows for a user-guiding prompt system
Example:
varoptions=[{name: "hello",description: "Hello world",// optionaloptions: [// optional, sets arguments (ex: hello [arg1]){name: "arg1",options: ["a","b","c"],// optional, sets selectable options for the argumentdescription: "argument 1"// optional}]},{name: "hello_again"// spaces are not allowed}]interface.gprompt("this is a guided prompt","type something",options,function(main,output){})Returns: logger
Functions:
- logger.log(string) - log string
- logger.slow(string,time,callback) - log string with typing animation
- logger.clear() - clear display
- logger.clearRow() - clear recent row
Example:
varlogger=interface.log("this is a log display")logger.log("This is logged onto the display")Arguments: title,startchar,callback
Returns: logger
Functions:
- logger.log(string) - log string
- logger.slow(string,time,callback) - log string with typing animation
- logger.clear() - clear display
- logger.clearRow() - clear recent row
Example:
varlogger=interface.terminal("this is a terminal",">",function(main,output){})logger.log("This is logged onto the display")Arguments: x,y,width,height,content,options,call
Example:
varlogger=interface.log("this is a log display")functiononKey(key){if(key=="ESC"){interface.box(-20,-3,40,6,"Exit?",{yes: function(m){m.done();// Removes box. BTW, m === interfacem.done();// removes log},no: function(m){m.done();// remove box}})}}interface.addListener("key",onKey);// add keypress listenerlogger.log("This is logged onto the display")Arguments: file,callback
Example:
interface.editor("./path/to/something.txt",function(main,file_contents,saved?){})









