gluon-remote-node

Node Version of gluon remote
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-remote-node.git
Log | Files | Refs | README | LICENSE

commit b5de6b04846ac9177f4c2f0b8f2ec4b3fef0fe77
parent 4ad4e422c17d570e697f49e65dc24b76e226f681
Author: MTRNord <mtrnord1@gmail.com>
Date:   Fri, 17 Jun 2016 23:47:42 +0200

Add some Colors

Diffstat:
Mgluon_web_remote-MOL.js | 8+++++---
Mgluon_web_remote-MOW.js | 8+++++---
Mgluon_web_remote-changeContact.js | 8+++++---
Mgluon_web_remote-changeGeo.js | 8+++++---
Mgluon_web_remote-changeName.js | 8+++++---
Mpackage.json | 1+
6 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/gluon_web_remote-MOL.js b/gluon_web_remote-MOL.js @@ -1,5 +1,7 @@ var program = require('commander'); var backend = require("./backend/commands.js"); +var chalk_lib = require('chalk'); +var chalk = new chalk_lib.constructor({enabled: true}); program .parse(process.argv); @@ -9,7 +11,7 @@ console.log(); var args = program.args; if (args.length < 3) { - console.error('Please set all required Arguments'); + console.error(chalk.bold.red('Please set all required Arguments')); process.exit(1); } if (args.length === 3) { @@ -18,10 +20,10 @@ if (args.length === 3) { var switchPosition = args[3] if (switchPosition === "on") { backend.activateMOL(ip, key) - console.log("Mesh on Lan activated successfully!"); + console.log(chalk.green("Mesh on Lan activated successfully!")); }else if (switchPosition === "off") { backend.deactivateMOL(ip, key) - console.log("Mesh on Lan deactivated successfully!"); + console.log(chalk.green("Mesh on Lan deactivated successfully!")); } } diff --git a/gluon_web_remote-MOW.js b/gluon_web_remote-MOW.js @@ -1,5 +1,7 @@ var program = require('commander'); var backend = require("./backend/commands.js"); +var chalk_lib = require('chalk'); +var chalk = new chalk_lib.constructor({enabled: true}); program .parse(process.argv); @@ -9,7 +11,7 @@ var args = program.args; console.log(); if (args.length < 3) { - console.error('Please set all required Arguments'); + console.error(chalk.bold.red('Please set all required Arguments')); process.exit(1); } if (args.length === 3) { @@ -18,10 +20,10 @@ if (args.length === 3) { var switchPosition = args[3] if (switchPosition === "on") { backend.activateMOW(ip, key) - console.log("Mesh on Wan activated successfully!"); + console.log(chalk.green("Mesh on Wan activated successfully!")); }else if (switchPosition === "off") { backend.deactivateMOW(ip, key) - console.log("Mesh on Wan deactivated successfully!"); + console.log(chalk.green("Mesh on Wan deactivated successfully!")); } } diff --git a/gluon_web_remote-changeContact.js b/gluon_web_remote-changeContact.js @@ -1,5 +1,7 @@ var program = require('commander'); var backend = require("./backend/commands.js"); +var chalk_lib = require('chalk'); +var chalk = new chalk_lib.constructor({enabled: true}); program .parse(process.argv); @@ -9,7 +11,7 @@ var args = program.args; console.log(); if (args.length < 4) { - console.error('Please set all required Arguments'); + console.error(chalk.bold.red('Please set all required Arguments')); process.exit(1); } if (args.length === 4) { @@ -18,7 +20,7 @@ if (args.length === 4) { var name = args[3] var email = args[4] backend.changeContact(ip, key, name, email, "") - console.log("Contact changed successfully!"); + console.log(chalk.green("Contact changed successfully!")); } if (args.length === 5) { var ip = args[1] @@ -27,6 +29,6 @@ if (args.length === 5) { var name = args[4] var email = args[5] backend.changeContact(ip, key, name, email, token) - console.log("Contact changed successfully!"); + console.log(chalk.green("Contact changed successfully!")); } console.log(); diff --git a/gluon_web_remote-changeGeo.js b/gluon_web_remote-changeGeo.js @@ -1,5 +1,7 @@ var program = require('commander'); var backend = require("./backend/commands.js"); +var chalk_lib = require('chalk'); +var chalk = new chalk_lib.constructor({enabled: true}); program .parse(process.argv); @@ -9,7 +11,7 @@ var args = program.args; console.log(); if (args.length < 5) { - console.error('Please set all required Arguments'); + console.error(chalk.bold.red('Please set all required Arguments')); process.exit(1); } if (args.length === 5) { @@ -19,7 +21,7 @@ if (args.length === 5) { var long = args[4] var alt = args[5] backend.changeGeo(ip, key, lat, long, alt, "") - console.log("Geolocation changed successfully!"); + console.log(chalk.green("Geolocation changed successfully!")); } if (args.length === 6) { var ip = args[1] @@ -29,7 +31,7 @@ if (args.length === 6) { var long = args[5] var alt = args[6] backend.changeGeo(ip, key, lat, long, alt, token) - console.log("Geolocation changed successfully!"); + console.log(chalk.green("Geolocation changed successfully!")); } console.log(); diff --git a/gluon_web_remote-changeName.js b/gluon_web_remote-changeName.js @@ -1,5 +1,7 @@ var program = require('commander'); var backend = require("./backend/commands.js"); +var chalk_lib = require('chalk'); +var chalk = new chalk_lib.constructor({enabled: true}); program .parse(process.argv); @@ -9,7 +11,7 @@ var args = program.args; console.log(); if (args.length < 3) { - console.error('Please set all required Arguments'); + console.error(chalk.bold.red('Please set all required Arguments')); process.exit(1); } if (args.length === 3) { @@ -17,7 +19,7 @@ if (args.length === 3) { var key = args[2] var newname = args[3] backend.changeName(ip, key, newname, "") - console.log("Hostname changed successfully!"); + console.log(chalk.green("Hostname changed successfully!")); } if (args.length === 4) { var ip = args[1] @@ -25,7 +27,7 @@ if (args.length === 4) { var token = args[3] var newname = args[4] backend.changeName(ip, key, newname, token) - console.log("Hostname changed successfully!"); + console.log(chalk.green("Hostname changed successfully!")); } console.log(); diff --git a/package.json b/package.json @@ -27,6 +27,7 @@ "homepage": "https://github.com/MTRNord/gluon_web_remote_node#readme", "dependencies": { "ajv": "^4.1.3", + "chalk": "^1.1.3", "commander": "^2.9.0", "ejs": "^2.4.2", "express": "^4.13.4",