some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-31 22:23:32 +03:00
parent 574f4ff48e
commit 9c905603a9
4 changed files with 41 additions and 19 deletions

View File

@ -38,25 +38,36 @@ module.CLI = core.ImageGridFeatures.Feature({
function(){ function(){
if(this.runtime == 'nw'){ if(this.runtime == 'nw'){
var argv = requirejs('nw.gui').App.argv var argv = requirejs('nw.gui').App.argv
// XXX
console.log('>>>>', argv)
} else if(this.runtime == 'node'){ } else if(this.runtime == 'node'){
var argv = process.argv var argv = process.argv
} }
// XXX for some reason this always contains --help in nw...
//console.log('>>>>', argv)
var cli = requirejs('commander') var cli = requirejs('commander')
cli
.version('0.0.1') .version('0.0.1')
.usage('[command] [options] ..') //.usage('[command] [options] ..')
.option('--features', 'list loaded features')
.command('index [path]', 'build and index of path') .option('--list-features', 'list loaded features')
//.command('index [path]', 'build an index of path')
.arguments('<action> [args]')
.action(function(action, args){
console.log('>>>>', action, args)
})
.parse(argv) .parse(argv)
// list features... // list features...
// XXX make this a core action... // XXX make this a core action... (???)
if(cli.features){ if(cli.listFeatures){
this.features.excluded.length > 0 this.features.excluded.length > 0
&& console.warn('Features excluded (%d):\n ', && console.warn('Features excluded (%d):\n ',
this.features.excluded.length, this.features.excluded.length,

View File

@ -46,12 +46,9 @@ module.ImageGridFeatures =
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// XXX stub action set -- this needs to be auto-generated... // setup actions and start...
var a = actions.Actions()
// setup actions...
ImageGridFeatures ImageGridFeatures
.setup(a, ['viewer-commandline']) .setup(['viewer-commandline'])
.start() .start()

View File

@ -9,6 +9,7 @@ define(function(require){ var module = {}
//var DEBUG = DEBUG != null ? DEBUG : true //var DEBUG = DEBUG != null ? DEBUG : true
args2array = require('lib/util').args2array args2array = require('lib/util').args2array
actions = require('lib/actions') actions = require('lib/actions')
@ -519,7 +520,21 @@ module.FeatureSet = {
} }
}, },
//
// .setup(<actions>, [<feature>, ...])
// -> <actions>
//
// .setup([<feature>, ...])
// -> <actions>
//
setup: function(obj, lst){ setup: function(obj, lst){
// if no explicit object is given, just the list...
if(lst == null){
lst = obj
obj = null
}
obj = obj || actions.Actions()
lst = lst.constructor !== Array ? [lst] : lst lst = lst.constructor !== Array ? [lst] : lst
var features = this.buildFeatureList(obj, lst) var features = this.buildFeatureList(obj, lst)
lst = features.features lst = features.features

View File

@ -262,15 +262,10 @@ $(function(){
m = Object.keys(m).filter(function(e){ return m[e] != null }) m = Object.keys(m).filter(function(e){ return m[e] != null })
console.log('Modules (%d):', m.length, m) console.log('Modules (%d):', m.length, m)
// XXX stub action set -- this needs to be auto-generated...
window.a = actions.Actions()
// used switch experimental actions on (set to true) or off (unset or false)...
//a.experimental = true
// setup actions... // setup actions...
viewer.ImageGridFeatures window.a = viewer.ImageGridFeatures
.setup(a, [ .setup([
'viewer-testing', 'viewer-testing',
// XXX this is not for production... // XXX this is not for production...
@ -278,6 +273,10 @@ $(function(){
]) ])
// used switch experimental actions on (set to true) or off (unset or false)...
//a.experimental = true
// report stuff... // report stuff...
// XXX we also have .conflicts and .missing // XXX we also have .conflicts and .missing
a.features.excluded.length > 0 a.features.excluded.length > 0