Do not falback to default IP for device but allow global definition

using environment variable.
This commit is contained in:
Julien Eluard
2017-06-04 18:36:33 +02:00
parent 09c977a795
commit 2def058077
3 changed files with 19 additions and 8 deletions
+2
View File
@@ -20,6 +20,8 @@ npm i -g status-dev-cli
* `--ip <device-ip>` to specify your device's IP address. If you don't know your device's IP address, just run `status-dev-cli scan`. The IP should be provided for every command you try to execute (except `scan`, of course)
Device IP can also be provided using the `STATUS_DEVICE_IP` environment variable (e.g. `STATUS_DEVICE_IP=192.168.0.2 status-dev-cli list`)
#### 1. Scanning the network
***status-dev-cli 3.2.0+, Status 0.9.8+***
+16 -7
View File
@@ -11,10 +11,19 @@ const mdns = require('mdns');
const pkgJson = require(__dirname + '/package.json');
const client = new watchman.Client();
const defaultIp = "localhost";
const defaultIp = process.env.STATUS_DEVICE_IP;
const statusDebugServerPort = 5561;
const StatusDev = require('./index.js');
function createStatusDev() {
const ip = cli.ip || defaultIp;
if (ip == null) {
console.error(chalk.red("You have provide your device IP using --ip."));
process.exit(1);
}
return new StatusDev({ip: ip});
}
function fromAscii(str) {
var hex = "";
for(var i = 0; i < str.length; i++) {
@@ -104,7 +113,7 @@ function printServerProblem() {
cli.command("add [contact]")
.description("Adds a contact")
.action(function (contact) {
var statusDev = new StatusDev({ip: cli.ip || defaultIp});
var statusDev = createStatusDev();
var contactData = getPackageData(contact);
if (contactData) {
statusDev.addContact(contactData, function(err, body) {
@@ -122,7 +131,7 @@ cli.command("add [contact]")
cli.command("remove [contactIdentity]")
.description("Removes a contact")
.action(function (contactIdentity) {
var statusDev = new StatusDev({ip: cli.ip || defaultIp});
var statusDev = createStatusDev();
var contact = null;
if (contactIdentity) {
@@ -145,7 +154,7 @@ cli.command("remove [contactIdentity]")
cli.command("refresh [contactIdentity]")
.description("Refreshes a debuggable contact")
.action(function (contactIdentity) {
var statusDev = new StatusDev({ip: cli.ip || defaultIp});
var statusDev = createStatusDev();
var contact = null;
if (contactIdentity) {
@@ -168,7 +177,7 @@ cli.command("refresh [contactIdentity]")
cli.command("switch-node <url>")
.description("Switches the current RPC node")
.action(function (url) {
var statusDev = new StatusDev({ip: cli.ip || defaultIp});
var statusDev = createStatusDev();
statusDev.switchNode(url, function(err, body) {
if (err) {
printMan();
@@ -183,7 +192,7 @@ cli.command("switch-node <url>")
cli.command("list")
.description("Displays all debuggable DApps and bots")
.action(function () {
var statusDev = new StatusDev({ip: cli.ip || defaultIp});
var statusDev = createStatusDev();
statusDev.listDApps(function (err, body) {
if (err) {
printMan();
@@ -208,7 +217,7 @@ cli.command("list")
cli.command("log <contactIdentity>")
.description("Returns log for a specified DApp or bot")
.action(function (contactIdentity) {
var statusDev = new StatusDev({ip: cli.ip || defaultIp});
var statusDev = createStatusDev();
statusDev.getLog(contactIdentity, function (err, body) {
if (err) {
printMan();
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "status-dev-cli",
"version": "3.2.8",
"version": "3.2.9",
"description": "CLI for Status",
"main": "index.js",
"bin": {