Node.js Shell A readline based shell with history support.
sudo npm install -g nosh
$ nosh
_
| |
_ __ ___ ___ | |__
| '_ \ / _ \ / __|| '_ \
| | | || (_) |\__ \| | | |
|_| |_| \___/ |___/|_| |_|
A basic list of commands to handle REST
The configuration is specified in the following order (last file overrides any previous config)
1. <installation-path>/config/settings.yaml
2. <HOME>/.noshrc
3. <current-directory>/noshrc
Please refer to the config/settings.yaml for all the options and override them as required.
start the shell with
nosh <url>
Currently basic auth is supported using this command.
...
> auth
(input) username ? <key-in-username-here>
(input) password ? <key-in-password-here>
auth for <username> set
# This command would set the basic auth headers based on
# input username, password
# to the subsequent commands
Toggle verbose mode. In verbose mode, you could see the full request and response from server.
Issues a 'GET' request.
$ nosh http://localhost:8000/api
...
> auth
...
> get students
# This would issue a GET request to http://localhost:8000/api/students
# with authentication headers set appropriately (based on auth command)
Issues a 'PUT'/'POST' request with request object. This is equivalent to -d '' from curl command line.
Issues a 'DELETE' request with request object.
Show and manipulate request object.
.. > request
{} // <-- displays current object
(input) key ? <enter key name>
(input) value ? <key value>
...> request
{}
(input) key ? xyz
(input) value ? 123
{"xyz":"123"}
# if value is empty, the key is removed from the request obj
To simply read a json file to request object, use this command
.. > read /home/test/my.json
loaded /home/test/my.json
{"name":"me", "value":.... }
.. >
To reset request obj (as you might not want to send it via headers)
..> reset request
For the rest url, navigation of it can be using the following commands.
# set the url to root
.. /a/b > //
.. / >
# set the url to parent
.. /a/b/c > ..
.. /a/b >
# append subpath to the url
.. /a > /b
.. /a/b >
Output from the response object can be printed in json (default) or yaml
.. > output yaml
output format set to yaml
.. > ...command..producing..output...
- id: xyz
...
Output fields can be filtered using this command (only first level entities given are shown)
.. > filter id name
filter set to id,name
.. > ...command..producing..output...
- id: xyz
name: abc
- id: 123
name: 333
While filter is on, the list of entries to screen can be limited via configuration limitItems
Command history is stored and loaded from ~/.nosh-history
To add an alias to a command
.. > newname="command and arguments"
...
.. > .alias
newname command and arguments
..
Use mustache syntax within string for subtitutions
.. > a="abc"
.. > b="get students/{{a}}"
.. > b
would issue 'get students/abc'
.. > input a
(input) a ? abc
.. > b="get students/{{input.a}}"
.. > b
would issue 'get students/abc'
nosh comes with pluggable modules and by default ships with a demo and rest module. In order to list the modules available, issue
.. > .modules
rest
demo
To switch between modules, issue
.. > .switch demo
context switched to: demo