Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,15 @@ node_modules
.strong-pm
test/minkelite.db
test/patch.file
intl/MSG.json
intl/de
intl/es
intl/fr
intl/it
intl/ja
intl/ko
intl/pt
intl/ru
intl/zh-Hans
intl/zh-Hant
intl/en/*.json
31 changes: 17 additions & 14 deletions bin/sl-meshadm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var Parser = require('posix-getopt').BasicParser;
var assert = require('assert');
var debug = require('debug')('strong-mesh-models:meshadm');
var fs = require('fs');
var g = require('strong-globalize');
var path = require('path');
var table = require('text-table');
var userHome = require('user-home');
Expand All @@ -14,13 +15,15 @@ var maybeTunnel = require('strong-tunnel');
assert(userHome, 'User home directory cannot be determined!');

function printHelp($0, prn) {
var USAGE = fs.readFileSync(require.resolve('./sl-meshadm.txt'), 'utf-8')
var USAGE = g.t('sl-meshadm.txt')
.replace(/%MAIN%/g, $0)
.trim();

prn(USAGE);
}

g.setRootDir(path.resolve(__dirname, '..'));

var argv = process.argv;
var $0 = process.env.CMD || path.basename(argv[1]);
var parser = new Parser([
Expand Down Expand Up @@ -50,7 +53,7 @@ while ((option = parser.getopt()) !== undefined) {
apiUrl = option.optarg;
break;
default:
console.error('Invalid usage (near option \'%s\'), try `%s --help`.',
g.error('Invalid usage (near option \'%s\'), try `{{%s --help}}`.',
option.optopt,
$0);
process.exit(1);
Expand Down Expand Up @@ -106,7 +109,7 @@ function runCommand(client, command) {
}

function unknown() {
console.error('Unknown command: %s, try `%s --help`.', command, $0);
g.error('Unknown command: %s, try `{{%s --help}}`.', command, $0);
process.exit(1);
}

Expand All @@ -116,7 +119,7 @@ function cmdCreateExecutor(client) {
client.executorCreate(driver, function(err, result) {
debug('exec-create: %j', err || result);
dieIf(err);
console.log('Created Executor id: %s token: %s',
g.log('Created Executor id: %s token: %s',
result.id, result.token);
});
}
Expand All @@ -143,7 +146,7 @@ function cmdListExecutors(client) {
}
console.log(table(data, {align: ['c', 'c', 'c', 'c', 'c', 'c']}));
} else {
console.log('No executors defined');
g.log('No executors defined');
}
});
}
Expand All @@ -154,7 +157,7 @@ function cmdRemoveExecutor(client) {
client.executorDestroy(id, function(err, result) {
debug('exec-remove: %j', err || result);
dieIf(err);
console.log('Removed executor: %s', id);
g.log('Removed executor: %s', id);
});
}

Expand All @@ -164,7 +167,7 @@ function cmdShutdownExecutor(client) {
client.executorShutdown(id, function(err, result) {
debug('exec-shutdown: %j', err || result);
dieIf(err);
console.log('Shutting down executor: %s', id);
g.log('Shutting down executor: %s', id);
});
}

Expand All @@ -173,7 +176,7 @@ function cmdCreateGateway(client) {
client.gatewayCreate(function(err, result) {
debug('gw-create: %j', err || result);
dieIf(err);
console.log('Created gateway controller id: %s token: %s',
g.log('Created gateway controller id: %s token: %s',
result.id, result.token);
});
}
Expand All @@ -193,7 +196,7 @@ function cmdListGateway(client) {
}
console.log(table(data, {align: ['c', 'c']}));
} else {
console.log('No gateway controllers defined');
g.log('No gateway controllers defined');
}
});
}
Expand All @@ -204,7 +207,7 @@ function cmdRemoveGateway(client) {
client.gatewayDestroy(id, function(err, result) {
debug('gw-remove: %j', err || result);
dieIf(err);
console.log('Removed gateway controller: %s', id);
g.log('Removed gateway controller: %s', id);
});
}

Expand All @@ -214,13 +217,13 @@ function cmdShutdownGateway(client) {
client.gatewayShutdown(id, function(err, result) {
debug('gw-shutdown: %j', err || result);
dieIf(err);
console.log('Shutting down gateway controller: %s', id);
g.log('Shutting down gateway controller: %s', id);
});
}

function mandatory(name) {
if (optind >= argv.length) {
console.error('Missing %s argument for %s, try `%s --help`.',
g.error('Missing %s argument for %s, try `{{%s --help}}`.',
name, command, $0);
process.exit(1);
}
Expand Down Expand Up @@ -249,10 +252,10 @@ function dieIf(err) {
// Split into first line, and the rest.
var msgs = msg.split('. ');

console.error('Command %j on %j failed with %s',
g.error('Command %j on %j failed with %s',
command, dieIf.url, msgs.shift());
if (msgs.length) {
console.error('%s', msgs.join('. ').trim());
g.error('%s', msgs.join('. ').trim());
}
process.exit(1);
}
43 changes: 0 additions & 43 deletions bin/sl-meshadm.txt

This file was deleted.

Loading