Skip to content

Commit bd5f9ba

Browse files
committed
(bluefox) support "iobroker -v"
1 parent 57acc88 commit bd5f9ba

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

lib/setup.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ var yargs = require('yargs')
5757
tools.appName + ' clean\n' +
5858
tools.appName + ' backup\n' +
5959
tools.appName + ' restore <backup name or path>' +
60-
tools.appName + ' <command> --timeout 5000')
60+
tools.appName + ' <command> --timeout 5000' +
61+
tools.appName + ' --version' +
62+
tools.appName + ' [adapter] -v')
6163
.default('objects', '127.0.0.1')
6264
.default('states', '127.0.0.1')
6365
.default('lang', 'en')
@@ -2200,8 +2202,23 @@ switch (yargs.argv._[0]) {
22002202
break;
22012203

22022204
default:
2203-
yargs.showHelp();
2204-
2205+
if (yargs.argv.v || yargs.argv.version) {
2206+
var iopckg;
2207+
if (yargs.argv._[0]) {
2208+
try {
2209+
iopckg = require('iobroker.' + yargs.argv._[0] + '/package.json');
2210+
} catch (err) {
2211+
iopckg = {version: '"' + yargs.argv._[0] + '" not found'};
2212+
}
2213+
} else {
2214+
iopckg = require(__dirname + '/../package.json');
2215+
}
2216+
console.log(iopckg.version);
2217+
} else {
2218+
yargs.showHelp();
2219+
}
2220+
processExit();
2221+
break;
22052222
}
22062223

22072224
// Save objects before exit

0 commit comments

Comments
 (0)