some more tweaking of the CLI...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-12-20 15:07:42 +03:00
parent d50f5c9c0e
commit 755a2696ed

View File

@ -31,11 +31,15 @@ var logger = {
root: true, root: true,
message: null, message: null,
log: null, log: null,
ig: null,
emit: function(e, v){ emit: function(e, v){
var msg = this.message var msg = this.message
var log = this.log = this.log || [] var log = this.log = this.log || []
// XXX HACK...
var ig = this.ig
// report progress... // report progress...
// XXX HACK -- need meaningful status... // XXX HACK -- need meaningful status...
if(e == 'queued' if(e == 'queued'
@ -158,8 +162,6 @@ var CLIActions = actions.Actions({
function(path){ function(path){
var that = this var that = this
this.logger = logger
// XXX is this correct??? // XXX is this correct???
path = path || this.location.path path = path || this.location.path
@ -208,6 +210,10 @@ module.CLI = core.ImageGridFeatures.Feature({
['ready', ['ready',
function(){ function(){
var that = this var that = this
this.logger = logger
logger.ig = that
// get the arguments... // get the arguments...
if(this.runtime.nw){ if(this.runtime.nw){
var argv = nw.App.argv var argv = nw.App.argv
@ -357,13 +363,15 @@ module.CLI = core.ImageGridFeatures.Feature({
keep_running = true keep_running = true
}) })
// XXX the problem with this is that it still tires /* // XXX the problem with this is that it still tires
// to find and run 'ig-index'... // to find and run 'ig-index'...
/* .command('index [path]', 'build an index of path')
.command('index [path]', 'build an index of path', function(path){ .action(function(path){
console.log('!!!!!! INDEX', path) console.log('!!!!!! INDEX', path)
//this.makeIndex(path)
}) })
*/ //*/
// XXX might be a good idea to make the action call // XXX might be a good idea to make the action call
// syntax like this: // syntax like this:
@ -377,7 +385,14 @@ module.CLI = core.ImageGridFeatures.Feature({
return return
} }
that[action](args) var res = that[action](args)
if(res instanceof Promise){
keep_running = true
res.then(function(){
process.exit()
})
}
}) })
.parse(argv) .parse(argv)