Giter Site home page Giter Site logo

threeletters / cli-gui2 Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 1.0 66 KB

Beautiful and functional console interface. Quickly create user-friendly interfaces. (Works over SSH)

License: GNU Affero General Public License v3.0

JavaScript 100.00%
npm-package nodejs cli-gui

cli-gui2's Introduction

CLI-GUI2

cligui

CLI-GUI - but much better. Graphical interface in command line.

Features

  1. List
  2. Checklist
  3. Search
  4. Table
  5. Prompt
  6. Guided prompt
  7. Log
  8. Terminal
  9. Box
  10. Editor

Documentation

Installation

npm install cligui2

Usage

var CliGui = require('cligui2');
var interface = new CliGui();

interface.stop - Stop interface

This stops the interface completely

interface.done - Remove layer

Used to remove "layers".

interface.reset - Reset interface

Resets interface

interface.addListener

Arguments: target,function

Adds a listener to a target

Available targets:

  1. key - Key presses

interface.removeListener

Arguments: target,function

Removes a listener from a target

interface.clearListeners

Arguments: target

clears listeners from a target

interface.list - List items

Arguments: title,items,call

The list function is very flexible. It can be called in four different ways.

  1. Options argument as an array of strings, call argument a function
  2. Options argument as an array of strings, call argument as an array of functions
  3. Options argument as an array of objects
  4. 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) {}
})

List

interface.checklist - List items as a checklist

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) {}
  }
])

Checklist

interface.search - List items as a searchable list

Arguments: title,items,call

Usage is same as the usage for the List function

Search

interface.table - List items as a table

Arguments: title,data

Data is an object

Example:

interface.table("This is a table",{
  thead: ["a","b","c"], // this is the sticky at the top
  data: [["hello","this","is"],["a","cool","test"],["tables","are","fun"], // the contents of the table
  sizes: [8,8,8], // optional: Sets the size for each column
  call: function(main,chosen) { // the callback
  
  }
})

Table

interface.prompt - Prompt the user (text input)

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) {

})

Prompt

#### interface.gprompt - Guided prompt Arguments: title,shadow,options,call

The guided prompt function allows for a user-guiding prompt system

Example:

var options = [
  {
    name: "hello",
    description: "Hello world", // optional
    options: [ // optional, sets arguments (ex: hello [arg1])
      {
      name: "arg1",
      options: ["a","b","c"], // optional, sets selectable options for the argument
      description: "argument 1" // optional
      }  
    ]
  },
  {
  name: "hello_again" // spaces are not allowed
  }
]
interface.gprompt("this is a guided prompt","type something",options,function(main,output) {

})

Guided prompt 1

Guided prompt 2

#### interface.log - Display Arguments: title

Returns: logger

Functions:

  1. logger.log(string) - log string
  2. logger.slow(string,time,callback) - log string with typing animation
  3. logger.clear() - clear display
  4. logger.clearRow() - clear recent row

Example:

var logger = interface.log("this is a log display")
logger.log("This is logged onto the display")

Log

interface.terminal - Terminal

Arguments: title,startchar,callback

Returns: logger

Functions:

  1. logger.log(string) - log string
  2. logger.slow(string,time,callback) - log string with typing animation
  3. logger.clear() - clear display
  4. logger.clearRow() - clear recent row

Example:

var logger = interface.terminal("this is a terminal",">",function(main,output) {

})
logger.log("This is logged onto the display")

Terminal

interface.box - Popup box

Arguments: x,y,width,height,content,options,call

Example:

var logger = interface.log("this is a log display")
function onKey(key) {
if (key == "ESC") {
interface.box(-20,-3,40,6,"Exit?",{
yes: function(m) {
m.done(); // Removes box. BTW, m === interface
m.done(); // removes log
},
no: function(m) {
m.done(); // remove box
}
})
}}


interface.addListener("key",onKey); // add keypress listener

logger.log("This is logged onto the display")

interface.editor - File editor

Arguments: file,callback

Example:

interface.editor("./path/to/something.txt",function(main,file_contents,saved?) {

})

Editor

cli-gui2's People

Contributors

andrews54757 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

iderp

cli-gui2's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.