A Node wrapper for sending Gogo commands to an OSGi environment
npm install gogo-shell> A Node wrapper for sending Gogo commands to an OSGi environment
```
$ npm install --save gogo-shell
Note: a Gogo shell must be running before invoking the connect method, otherwise a connection error will be thrown.
`js
var GogoShell = require('gogo-shell');
var gogoShell = new GogoShell();
var config = {
port: 11311
};
gogoShell.connect(config)
.then(function() {
return gogoShell.sendCommand('lb');
})
.then(function(data) {
// Do something with response data
gogoShell.end();
});
`
GogoShell is an instance of net.Socket and inherits all it's properties, methods, and events.
#### options
Type: object
The GogoShell constructor can also be passed the same configuration options as the net.Socket constructor.
##### debug
type: boolean
If set to true, prints all commands sent to the server, and all response data from the server to stdout.
#### examples
`js
var GogoShell = require('gogo-shell');
var gogoShell = new GogoShell({
debug: true
});
`
Connects to a TCP server which allows you to send Gogo commands to an OSGi environment. Returns a Promise which resolves when the server is ready to receive commands.
#### options
Type: object
##### host
Type: string127.0.0.1
Default:
##### port
Type: numbertrue
Required:
See socket.connect method for other options and their default values.
#### examples
`js
var GogoShell = require('gogo-shell');
var gogoShell = new GogoShell();
var config = {
port: 11311
};
gogoShell.connect(config)
.then(function() {
// gogoShell.sendCommand(...);
});
`
Returns Promise that resolves with array of available commands, or object literal containing information on specified command.
##### command
Type: string
The Gogo command to retieve help info for.
#### examples
`js`
gogoShell.help()
.then(function(data) {
// data = array of available commands
});
`js`
gogoShell.help('install')
.then(function(data) {
// data = object literal containing api information for specified command
});
Sends Gogo command to an OSGi environment. Returns a Promise that resolves with the response data.
##### command
Type: string
The Gogo command that will be sent to the OSGi environment.
##### options
Type: string
Additional parameters, flags, and options that will be joined with the command argument.
#### examples
`js`
gogoShell.sendCommand('lb', '-s')
.then(function(data) {
// data = list of installed bundles with symbolic name
});
Chaining commands.
`js
var GogoShell = require('gogo-shell');
var gogoShell = new GogoShell();
var config = {
port: 11311
};
gogoShell.connect(config)
.then(function() {
return gogoShell.sendCommand('lb');
})
.then(function(data) {
// data = response from 'lb'
return gogoShell.sendCommand('another command');
})
.then(function(data) {
// data = response from 'another command'
// Using socket.end for closing connection, otherwise Node process wouldn't end
gogoShell.end();
});
``
MIT