Skip to content

Commit

Permalink
Merge pull request #41 from chombium/node-lts-refactoring
Browse files Browse the repository at this point in the history
Node v6.9.5 refactoring and new code formatting
  • Loading branch information
mcollina authored May 2, 2017
2 parents a2e8743 + 7485911 commit 5c3f6f9
Show file tree
Hide file tree
Showing 21 changed files with 1,386 additions and 1,337 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ docs
mosquitto.db
*.pdf
db/

.project
.settings
15 changes: 0 additions & 15 deletions .jshintrc

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Report bugs at the [Eclipse
Bugzilla](https://bugs.eclipse.org/bugs/buglist.cgi?component=Core&product=Ponte&resolution=---)
and join the [mailing list](https://dev.eclipse.org/mailman/listinfo/ponte-dev).

[![Standard - JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

## Installation

Ponte is a node.js application, so it needs [node.js](http://nodejs.org)
Expand Down Expand Up @@ -389,6 +391,10 @@ http://eclipse.org/proposals/technology.ponte/

## Contributing to Ponte

* Install [JavaScript Standard Style] (https://github.com/feross/standard)
```bash
$ npm i -g standard
```
* Check out the latest master to make sure the feature hasn't been
implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't
Expand Down
89 changes: 46 additions & 43 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,99 +1,102 @@
'use strict';
'use strict'
/*******************************************************************************
* Copyright (c) 2013-2014 Matteo Collina
* Copyright (c) 2013-2017 Matteo Collina
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Matteo Collina - initial API and implementation and/or initial documentation
* Jovan Kostovski - added standard js for source code style checking
*******************************************************************************/

var commander = require("commander");
var pkg = require("../package.json");
var path = require("path");
/**
* CLI module
* @description A module to hanlde the commandline and starting of Ponte
* @module
*/
var commander = require('commander')
var pkg = require('../package.json')
var path = require('path')

module.exports = function(args, done) {
module.exports = function (args, done) {
args = args || []

args = args || [];

var program = new commander.Command();
var server = null;
var runned = false;
var program = new commander.Command()

program
.version(pkg.version)
.option("-m, --mqtt-port <n>", "the mqtt port to listen to", parseInt)
.option("-p, --http-port <n>", "the http port to listen to", parseInt)
.option("-a, --coap-port <n>", "the coap port to listen to", parseInt)
.option("--host <host>", "the host to listen to")
.option("--coap-host <host>", "the host to listen to for coap requests")
.option("--mqtt-host <host>", "the host to listen to for mqtt requests")
.option("--http-host <host>", "the host to listen to for http requests")
.option("-d, --db <path>", "the path were to store the database")
.option("-c, --config <c>", "the config file to use (override every other option)")
.option("-v, --verbose", "set the bunyan log to INFO")
.option("--very-verbose", "set the bunyan log to DEBUG");

program.parse(args);
.option('-m, --mqtt-port <n>', 'the mqtt port to listen to', parseInt)
.option('-p, --http-port <n>', 'the http port to listen to', parseInt)
.option('-a, --coap-port <n>', 'the coap port to listen to', parseInt)
.option('--host <host>', 'the host to listen to')
.option('--coap-host <host>', 'the host to listen to for coap requests')
.option('--mqtt-host <host>', 'the host to listen to for mqtt requests')
.option('--http-host <host>', 'the host to listen to for http requests')
.option('-d, --db <path>', 'the path were to store the database')
.option('-c, --config <c>', 'the config file to use (override every other option)')
.option('-v, --verbose', 'set the bunyan log to INFO')
.option('--very-verbose', 'set the bunyan log to DEBUG')

program.parse(args)

var opts = {
logger: {},
http: {},
mqtt: {},
coap: {},
persistence: {}
};
}

if (program.verbose) {
opts.logger.level = 30;
opts.logger.level = 30
} else if (program.veryVerbose) {
opts.logger.level = 20;
opts.logger.level = 20
}

if (program.httpPort) {
opts.http.port = program.httpPort;
opts.http.port = program.httpPort
}

if (program.mqttPort) {
opts.mqtt.port = program.mqttPort;
opts.mqtt.port = program.mqttPort
}

if (program.coapPort) {
opts.coap.port = program.coapPort;
opts.coap.port = program.coapPort
}

if (program.host) {
opts.coap.host = program.host;
opts.mqtt.host = program.host;
opts.http.host = program.host;
opts.coap.host = program.host
opts.mqtt.host = program.host
opts.http.host = program.host
}

if (program.coapHost) {
opts.coap.host = program.coapHost;
opts.coap.host = program.coapHost
}

if (program.mqttHost) {
opts.mqtt.host = program.mqttHost;
opts.mqtt.host = program.mqttHost
}

if (program.httpHost) {
opts.http.host = program.httpHost;
opts.http.host = program.httpHost
}

if (program.db) {
opts.persistence.path = program.db;
opts.persistence.type = "level";
opts.persistence.path = program.db
opts.persistence.type = 'level'
}

if (program.config) {
opts = require(path.resolve(program.config));
opts = require(path.resolve(program.config))
}

return this(opts, done);
};
return this(opts, done)
}
Loading

0 comments on commit 5c3f6f9

Please sign in to comment.