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(){
if(this.runtime == 'nw'){
var argv = requirejs('nw.gui').App.argv
// XXX
console.log('>>>>', argv)
} else if(this.runtime == 'node'){
var argv = process.argv
}
// XXX for some reason this always contains --help in nw...
//console.log('>>>>', argv)
var cli = requirejs('commander')
cli
.version('0.0.1')
.usage('[command] [options] ..')
.option('--features', 'list loaded features')
.command('index [path]', 'build and index of path')
//.usage('[command] [options] ..')
.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)
// list features...
// XXX make this a core action...
if(cli.features){
// XXX make this a core action... (???)
if(cli.listFeatures){
this.features.excluded.length > 0
&& console.warn('Features excluded (%d):\n ',
this.features.excluded.length,

View File

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

View File

@ -9,6 +9,7 @@ define(function(require){ var module = {}
//var DEBUG = DEBUG != null ? DEBUG : true
args2array = require('lib/util').args2array
actions = require('lib/actions')
@ -519,7 +520,21 @@ module.FeatureSet = {
}
},
//
// .setup(<actions>, [<feature>, ...])
// -> <actions>
//
// .setup([<feature>, ...])
// -> <actions>
//
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
var features = this.buildFeatureList(obj, lst)
lst = features.features

View File

@ -262,15 +262,10 @@ $(function(){
m = Object.keys(m).filter(function(e){ return m[e] != null })
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...
viewer.ImageGridFeatures
.setup(a, [
window.a = viewer.ImageGridFeatures
.setup([
'viewer-testing',
// 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...
// XXX we also have .conflicts and .missing
a.features.excluded.length > 0