|
1 |
| -shell.js |
2 |
| -======== |
| 1 | +josh.js 0.1 |
| 2 | +=========== |
3 | 3 |
|
4 |
| -Toolkit for building bash-like shell in the browser, including full readline support |
| 4 | +***Javascript Online SHell*** provides a toolkit for building bash-like command line consoles for web pages. It consists of the following components: |
| 5 | + |
| 6 | +* `readline.js` - full readline support for ctrl sequences, tab, history, etc. |
| 7 | +* `shell.js` - visual presentation of the shell and command handling |
| 8 | +* `pathhandler.js` - provide cd, ls, pwd and path completion toolikit |
| 9 | +* `history.js` - localStorage backed command history |
| 10 | + |
| 11 | +## License |
| 12 | +josh.js is licensed under the Apache 2.0 License |
| 13 | + |
| 14 | +## Status |
| 15 | + |
| 16 | +* code is ready for use |
| 17 | +* needs minified versions of complete toolkit and just readline.js |
| 18 | +* needs code documentation and documenation site |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +Until documentation is written, refer to `index.html` and `example.js` for a sample implementation of a shell with path completion. |
| 23 | + |
| 24 | +## Components |
| 25 | +***josh*** is built from 4 components and can be used in part or in full. |
| 26 | + |
| 27 | +### readline.js |
| 28 | + |
| 29 | +`readline.js` has no dependencies on any outside libraries, although it requires either `history.js` or an object implementing the same calls. |
| 30 | + |
| 31 | +It implements key trapping to bring [GNU Readline](http://cnswww.cns.cwru.edu/php/chet/readline/readline.html) like line editing to the browser. It can be used by itself to bring readline support to custom data entry fields or in conjunction with `shell.js` to create a full console. |
| 32 | + |
| 33 | +### shell.js |
| 34 | +`shell.js` has external dependencies of [jQuery](http://jquery.com/), [Underscore](http://underscorejs.org/) and internal dependencies of `readline.js` and `history.js`. |
| 35 | + |
| 36 | +It provides a simple console UI, using a *panel* for the console viewport and an auto-scrolling *view* inside the panel. It uses Underscore templates for generating the view html, although any template generator can be substituted as long as it can be expressed in the form of a function that takes a JSON object of arguments and returns an html string. |
| 37 | + |
| 38 | +It also implements command handling so that new commands can be added by name with execution and completion handlers. Out of the box, `shell.js` provides the following commands: |
| 39 | +* help - list all known commands (including user added) |
| 40 | +* clear - clear the "screen" i.e. viewport |
| 41 | +* history - show the command history captured by `readline.js` in `history.js` |
| 42 | + |
| 43 | +### pathhandler.js |
| 44 | +`pathhandler.js` is a mix in to easily add the `cd`, `ls` and `pwd` commands as well as path completion. It has the same external dependencies of [jQuery](http://jquery.com/), [Underscore](http://underscorejs.org/) as `shell.js` and also uses Underscore templating. |
| 45 | + |
| 46 | +By implementing the functions `getNode` and `getChildNodes`, this library adds path traversal, discovery and completion just like a bash shell. |
| 47 | + |
| 48 | +### history.js |
| 49 | +`history.js` implements a localStorage back command history storage that persists over page changes and reloads. It is used by the `shell.js` history command to list all executed commands, and by `readline.js` for up/down arrow and reverse search capabilities. |
0 commit comments