reworking cli...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-12-11 17:18:02 +03:00
parent 11490cc358
commit a19391d085
4 changed files with 33 additions and 5 deletions

View File

@ -114,6 +114,9 @@ module.CLI = core.ImageGridFeatures.Feature({
var argv = process.argv
}
var keep_running = false
// XXX this is not portable...
//var package = requirejs('fs-extra').readJSONSync('./package.json')
@ -200,8 +203,7 @@ module.CLI = core.ImageGridFeatures.Feature({
})
.option('repl, --repl', 'start an ImageGrid REPL', function(){
// XXX this is broken in node for some reason...
var repl = requirejs('repl')
var repl = nodeRequire('repl')
// setup the global ns...
global.ig =
@ -216,6 +218,8 @@ module.CLI = core.ImageGridFeatures.Feature({
repl.start({
prompt: 'ig> ',
useGlobal: true,
input: process.stdin,
output: process.stdout,
@ -229,11 +233,15 @@ module.CLI = core.ImageGridFeatures.Feature({
// npm link nwjs
// nw install 0.14.5-sdk
.option('gui, --gui', 'start ImageGrid.Viewer', function(){
throw new Error('ig: GUI startup not implemented.')
var path = requirejs('path')
requirejs('child_process')
.spawn(requirejs('nwjs'), [
path.dirname(process.argv[1]).replace(/\\/g, '/') + '/'])
keep_running = true
})
// XXX the problem with this is that it still tires
@ -251,11 +259,19 @@ module.CLI = core.ImageGridFeatures.Feature({
.action(function(action, args){
// XXX
//console.log('>>>>', action, args, !!that[action])
if(!that[action]){
console.error('No such action:', action)
return
}
that[action](args)
})
.parse(argv)
!keep_running
&& this.stop()
}]
],
})

View File

@ -323,7 +323,15 @@ var LifeCycleActions = actions.Actions({
return !this.__stop_handler },
isReady: function(){
return !!this.__ready },
// XXX is this the right name for this???
get runtimeState(){
return this.isStarted() ?
'started'
: this.isStarted() ?
'stopped'
: this.isReady() ?
'ready'
: undefined },
start: ['- System/',
doc`Start core action/event

View File

@ -59,7 +59,7 @@ var URLHistoryActions = actions.Actions({
// will have no effect...
get url_history_pinned(){
var url_history = this.url_history
return Object.keys(url_history)
return Object.keys(url_history || {})
.reduce(function(res, k){
if(url_history[k].pinned){
res[k] = url_history[k]

View File

@ -8,7 +8,11 @@
//var DEBUG = DEBUG != null ? DEBUG : true
//require('v8-compile-cache')
require('v8-compile-cache')
// NOTE: this fixes several issues with lib/util conflicting with stuff...
// XXX this might also pose some other issues within the repl, needs
// testing...
require('repl')
require('./cfg/requirejs')