chore(cloudcmd) add choose

This commit is contained in:
coderaiser 2017-03-05 14:15:42 +02:00
parent f1310f303f
commit 076077223a
2 changed files with 17 additions and 3 deletions

View file

@ -9,6 +9,13 @@ const exit = require(DIR_SERVER + 'exit');
const config = require(DIR_SERVER + 'config');
const env = require(DIR_SERVER + 'env');
const choose = (a, b) => {
if (!a && typeof a !== 'boolean')
return b;
return a;
};
const argv = process.argv;
const args = require('minimist')(argv.slice(2), {
string: [
@ -52,10 +59,10 @@ const args = require('minimist')(argv.slice(2), {
prefix : config('prefix') || '',
progress : config('progress'),
console : config('console'),
terminal : env.bool('terminal') || config('terminal'),
terminal : choose(env.bool('terminal'), config('terminal')),
'terminal-path': env('terminal_path') || config('terminalPath'),
'config-dialog': env.bool('config_dialog') || config('configDialog'),
'config-dialog': choose(env.bool('config_dialog'), config('configDialog')),
'one-panel-mode': config('onePanelMode'),
'html-dialogs': config('htmlDialogs')
},

View file

@ -4,7 +4,14 @@ const env = process.env;
const up = (a) => a.toUpperCase();
module.exports = parse;
module.exports.bool = (name) => Boolean(parse(name));
module.exports.bool = (name) => {
const value = parse(name);
if (value === 'false')
return false;
return value;
};
function parse(name) {
const small = `cloudcmd_${name}`;