cmdserver (v0.0.1)
client/server command line apps made easy (think tmux
)
Install
npm install cmdserver
API example
var util = ;var app = processargv; var stacks = vegetables: meats: ; app app ; app ; app ; app;
client/server model
You can start a server by doing this:
± node example.js -S /tmp/food.socket
file /tmp/food.socket
debug listening: '/tmp/food.socket'
Then, in another terminal session, you can connect to the server by running the same command:
± node example.js -S /tmp/food.socket
file /tmp/food.socket
/tmp/food.socket < help
/tmp/food.socket >
add <thing> <stack>: add a thing to a specific stack
method [push|unshift] method for adding. Defaults to `push`
show <stack>: show the contents of a specific stack
list stacks: show all of the stacks
new <stack>: make a brand new stack, hhyyeaaaaa
/tmp/food.socket < add beef meats
/tmp/food.socket > pushed `beef` to `meats`
/tmp/food.socket < add 'cold cuts' meats
/tmp/food.socket > pushed `cold cuts` to `meats`
/tmp/food.socket < add 'pork shoulder' meats method=unshift
/tmp/food.socket > unshifted `pork shoulder` to `meats`
/tmp/food.socket < new 'seafood'
/tmp/food.socket > adding new stack `seafood`
You can have as many clients open as you want, go nuts:
# in yet another terminal session
± node example.js -S /tmp/food.socket
file /tmp/food.socket
/tmp/food.socket < list stacks
/tmp/food.socket > [ 'vegetables',
'meats',
'seafood' ]
/tmp/food.socket < show meats
/tmp/food.socket > [ 'pork shoulder',
'beef',
'cold cuts' ]
# you can also perform one-off commands
± node example.js -S /tmp/food.socket "list stacks"
[ 'vegetables',
'meats',
'seafood' ]
Using as a REPL
If you don't pass any arguments, it will drop you into a REPL
± node example.js
example.js> help
debug
add <thing> <stack>: add a thing to a specific stack
method [push|unshift] method for adding. Defaults to `push`
show <stack>: show the contents of a specific stack
list stacks: show all of the stacks
new <stack>: make a brand new stack, hhyyeaaaaa
example.js> help list stacks
debug
list stacks: show all of the stacks
example.js>
TODO
- add port, host:port connection options
- add more tests, geez!