main: create a simple config window to set CLI arguments when executed without argument
This commit is contained in:
parent
94fa41ca3a
commit
59326dff48
7 changed files with 325 additions and 14 deletions
|
|
@ -30,7 +30,7 @@ var options = {
|
|||
},
|
||||
'd':{alias:'debug',type:'boolean',describe:'log received osc messages in the console'},
|
||||
'n':{alias:'no-gui',type:'boolean',describe:'disable default gui'},
|
||||
'g':{alias:'gui-only',type:'string',describe:'server\'s ip:port, default to localhost:8080, only launch the gui (a server instance must be running)'},
|
||||
'g':{alias:'gui-only',type:'string',describe:'server\'s ip:port, default to localhost:8080'},
|
||||
't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'},
|
||||
'e':{alias:'examples',type:'boolean',describe:'list examples instead of recent sessions'}
|
||||
}
|
||||
|
|
@ -57,6 +57,9 @@ var argv = require('yargs')
|
|||
argv = argv.argv
|
||||
|
||||
var config = function(){try {return JSON.parse(fs.readFileSync(configFile,'utf-8'))} catch(err) {return {}}}(),
|
||||
defaultConfig
|
||||
|
||||
var makeDefaultConfig = function(argv){
|
||||
defaultConfig = {
|
||||
argv:argv,
|
||||
presetPath : process.cwd(),
|
||||
|
|
@ -76,11 +79,11 @@ var config = function(){try {return JSON.parse(fs.readFileSync(configFile,'utf-8
|
|||
var appAddresses = []
|
||||
|
||||
Object.keys(ifaces).forEach(function (ifname) {
|
||||
for (i=0;i<ifaces[ifname].length;i++) {
|
||||
if (ifaces[ifname][i].family == 'IPv4') {
|
||||
appAddresses.push('http://' + ifaces[ifname][i].address + ':' + (argv.p || 8080))
|
||||
}
|
||||
}
|
||||
for (i=0;i<ifaces[ifname].length;i++) {
|
||||
if (ifaces[ifname][i].family == 'IPv4') {
|
||||
appAddresses.push('http://' + ifaces[ifname][i].address + ':' + (argv.p || 8080))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return appAddresses
|
||||
|
|
@ -101,9 +104,14 @@ var config = function(){try {return JSON.parse(fs.readFileSync(configFile,'utf-8
|
|||
return style
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
makeDefaultConfig(argv)
|
||||
|
||||
module.exports = {
|
||||
argv:argv,
|
||||
options:options,
|
||||
makeDefaultConfig:makeDefaultConfig,
|
||||
read:function(key){
|
||||
var x = config[key] || defaultConfig[key]
|
||||
return x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue