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

View File

@ -323,7 +323,15 @@ var LifeCycleActions = actions.Actions({
return !this.__stop_handler }, return !this.__stop_handler },
isReady: function(){ isReady: function(){
return !!this.__ready }, 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/', start: ['- System/',
doc`Start core action/event doc`Start core action/event

View File

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

View File

@ -8,7 +8,11 @@
//var DEBUG = DEBUG != null ? DEBUG : true //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') require('./cfg/requirejs')