Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Anode Command Line Interface

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 samples
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 cli_myboard.jpg
Octocat-spinner-32 cli_myboard_small.jpg
Octocat-spinner-32 design.md
README.md

Anode Command Line Interface

ACLI is a command line interface, developed mainly for the use in the anode project.

Why developing a new CLI component?

Before starting to work on this module, few other existing open source CLI (command line interface) components were evaluated, like

Each of the above components and the others that were examined had some of the required functionality, but did not support other features that we needed.
The most suitable library for this task was the GCLI component, which was the main inspiration for implementing ACLI, mostly at the area of the commands structure.

Features

  • Manages environment variables and use them as part of the command line.
  • Supports plugins- remote commands integrated into the console, using docRouter metadata.
    Supporting plugins with client side processing and styling.
  • Keeps command line history, plugins and environment variables in offline storage.
  • My Board feature to keep command execution results on-screen.
  • Visualizes json data as an html table with auto collapsing deep elements.
  • Supports working in parallel with few instances/tabs of the console.
  • Supports broadcasting requests when working on a farm.

Example for 'My Board' feature

Getting Started

The following is an example of how to quickly start using the component.
See the basic sample under the samples directory.

html file:

<body>

    <div class="cli-output" id="cliOutput"></div>
    <div class="cli-my-board" id="cliMyBoard">
        <div class="cli-my-board-close"></div>
        <div class="cli-my-board-title">My Board</div>
    </div>
    <div class="cli-input-container">
        <span class="cli-promptText" id="cliPrompt">></span>
        <input id="cliInput" class="cli-input" type="text">
    </div>

</body>

js file:

var cli =  $("#cliInput").cli(
       {
           resultsContainer: $("#cliOutput"),
           promptControl: $("#cliPrompt"),
           myBoard: $("#cliMyBoard"),
           environment: {user: { type: 'string', value: '', description: 'The current user' }},
           commands: getCommands(),
           context: { some: 'object' },
           welcomeMessage: "Welcome to anode console!<br/>. Type <b>help</b> to start exploring the commands currently supported!<br/>"
       }
   );

// create default commands
function getCommands() {
    var commands = [];

    var addCommand = {
        name: 'add',
        description: 'add two numbers',
        usage: 'add num1 num2',
        example: 'add 4 5',
        params: [
            {
                name: 'num1',
                description: 'first number',
                type: 'number'
            },
            {
                name: 'num2',
                description: 'second number',
                type: 'number'
            }
        ],
        exec: function(args, context) {
            return args.num1 + args.num2;
        }
    }

    var asyncCommand = {
        name: 'async',
        description: 'simulates async command',
        usage: 'async [text]',
        example: 'async',
        params: [
            {
                name: 'text',
                description: 'some text to show',
                type: 'string',
                defaultValue: null // make this an optional  argument
            }
        ],
        exec: function(args, context) {
            var promise = context.createPromise();

            // simulating some async long-processing action
            setTimeout(function(){
                var result = args.text || "you didn't enter text";
                promise.resolve(result);
            }, 1000);

            return promise;
        }
    }

    commands.push(addCommand);
    commands.push(asyncCommand);

    return commands;
}

Advanced Use

See plugins under samples folder for a node JS sample application that extends the console with commands from the server (plug-ins)!

Main Requirements

Main requirements and detailed design can be found in the design.md file.

Enjoy!

Something went wrong with that request. Please try again.