JOSH.js – Javascript Online SHell



JOSH.js – Javascript Online SHell

0 0


sdjs-josh-talk


On Github sdether / sdjs-josh-talk

JOSH.js

Javascript Online SHell

Because every site deserves a CLI
Arne Claassen
@sdether
MindTouch

JOSH.js

Javascript Online SHell

Because every site deserves a CLI
Arne Claassen
@sdether
MindTouch

WHAT is READLINE

"GNU readline is a software library that provides line-editing and history capabilities for interactive programs with a command-line interface, such as Bash."

josh.js provides native javascript readline support

What's in josh.js?

  • Readline
  • History
    • by default backed by local storage
  • Killring
    • clipboard on steroids
  • Shell
    • Basic text shell
    • Tab completion
    • Reverse search
    • Command handling
  • PathHandler
    • support for unix style path hierarchy navigation

BUILT-IN COMMANDS

  • Shell
    • clear
    • history
    • help
  • PathHandler
    • cd
    • ls
    • pwd

A simple shell

Command Handlers

shell.setCommandHandler("command", {
  exec: function (cmd, args, callback) {
    ...
  }
);

Completion Handlers

shell.setCommandHandler("command", {
  exec: ...,
  completion: function (cmd, arg, line, callback) {
    ...
  }
);

Path Handling

Node format
{
  name: 'localname',
  path: '/full/path/to/localname'
}
getNode
pathhandler.getNode = function(path, callback) {
  // call callback with a node
};
getChildNodes
pathhandler.getChildNodes = function(node, callback) {
  // call callback with an array of nodes
}

JOSH.js @ MindTouch

Docs & Examples

THANKS

Arne Claassen
@sdether
MindTouch