2015-12-31 07:00:18 +03:00
|
|
|
/**********************************************************************
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
|
|
define(function(require){ var module = {}
|
|
|
|
|
|
|
|
|
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
|
|
|
|
|
|
|
|
|
var actions = require('lib/actions')
|
|
|
|
|
var features = require('lib/features')
|
|
|
|
|
|
|
|
|
|
var data = require('data')
|
|
|
|
|
var images = require('images')
|
|
|
|
|
|
|
|
|
|
var core = require('features/core')
|
|
|
|
|
var base = require('features/base')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************/
|
2016-01-01 01:58:55 +03:00
|
|
|
// XXX what we need here is:
|
|
|
|
|
// - base introspection
|
|
|
|
|
// - list features
|
|
|
|
|
// - list actions
|
|
|
|
|
// - list action scripts / commands
|
|
|
|
|
// - call action
|
|
|
|
|
// - call action script (a-la git commands)
|
|
|
|
|
//
|
|
|
|
|
// XXX the main functionality:
|
|
|
|
|
// - make previews
|
|
|
|
|
// - make index
|
|
|
|
|
// - merge
|
|
|
|
|
// - clone
|
2015-12-31 07:00:18 +03:00
|
|
|
|
|
|
|
|
var CLI =
|
|
|
|
|
module.CLI = core.ImageGridFeatures.Feature({
|
|
|
|
|
title: '',
|
|
|
|
|
doc: '',
|
|
|
|
|
|
|
|
|
|
tag: 'commandline',
|
|
|
|
|
depends: ['base'],
|
|
|
|
|
|
|
|
|
|
isApplicable: function(){
|
2016-01-01 02:22:17 +03:00
|
|
|
return this.runtime == 'node' || this.runtime == 'nw' },
|
2015-12-31 07:00:18 +03:00
|
|
|
|
|
|
|
|
handlers: [
|
|
|
|
|
['start',
|
|
|
|
|
function(){
|
2015-12-31 22:58:41 +03:00
|
|
|
// get the arguments...
|
2015-12-31 07:00:18 +03:00
|
|
|
if(this.runtime == 'nw'){
|
|
|
|
|
var argv = requirejs('nw.gui').App.argv
|
2015-12-31 22:23:32 +03:00
|
|
|
|
2016-01-02 19:41:11 +03:00
|
|
|
// XXX appears to have a stray '--help' lodged in
|
|
|
|
|
// all the time...
|
|
|
|
|
// ...need to test this with a packed exec...
|
2015-12-31 22:23:32 +03:00
|
|
|
console.log('>>>>', argv)
|
|
|
|
|
|
2015-12-31 07:00:18 +03:00
|
|
|
} else if(this.runtime == 'node'){
|
|
|
|
|
var argv = process.argv
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-12-31 10:37:21 +03:00
|
|
|
var cli = requirejs('commander')
|
2015-12-31 22:23:32 +03:00
|
|
|
cli
|
2015-12-31 22:58:41 +03:00
|
|
|
// XXX get the version from config...
|
2015-12-31 07:00:18 +03:00
|
|
|
.version('0.0.1')
|
2015-12-31 22:23:32 +03:00
|
|
|
//.usage('[command] [options] ..')
|
|
|
|
|
|
2016-01-02 23:27:50 +03:00
|
|
|
// list features...
|
|
|
|
|
// XXX make this a core action... (???)
|
|
|
|
|
.option('--list-features', 'list loaded features', function(){
|
|
|
|
|
// excluded...
|
|
|
|
|
this.features.excluded.length > 0
|
|
|
|
|
&& console.warn('Features excluded (%d):\n ',
|
|
|
|
|
this.features.excluded.length,
|
|
|
|
|
this.features.excluded.join('\n '))
|
|
|
|
|
|
|
|
|
|
// not applicable...
|
|
|
|
|
console.log('Features not applicable (%d):\n ',
|
|
|
|
|
this.features.unapplicable.length,
|
|
|
|
|
this.features.unapplicable.join('\n '))
|
|
|
|
|
|
|
|
|
|
// loaded...
|
|
|
|
|
console.log('Features loaded (%d):\n ',
|
|
|
|
|
this.features.features.length,
|
|
|
|
|
this.features.features.join('\n '))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// list actions...
|
|
|
|
|
// XXX this is a bit pointless as single actions are
|
|
|
|
|
// meaningless when no state is stored...
|
|
|
|
|
.option('--list-actions', 'list loaded actions', function(){
|
|
|
|
|
console.log('Actions loaded (%d):\n ',
|
|
|
|
|
this.length,
|
|
|
|
|
Object.keys(this.getDoc()).join('\n '))
|
|
|
|
|
})
|
2015-12-31 22:23:32 +03:00
|
|
|
|
2016-01-03 03:03:36 +03:00
|
|
|
// XXX the problem with this is that it still tires
|
|
|
|
|
// to find and run 'ig-index'...
|
|
|
|
|
/*
|
|
|
|
|
.command('index [path]', 'build an index of path', function(path){
|
|
|
|
|
console.log('!!!!!! INDEX', path)
|
|
|
|
|
})
|
|
|
|
|
*/
|
2015-12-31 22:23:32 +03:00
|
|
|
|
|
|
|
|
.arguments('<action> [args]')
|
|
|
|
|
.action(function(action, args){
|
2016-01-01 01:58:55 +03:00
|
|
|
// XXX
|
2015-12-31 22:23:32 +03:00
|
|
|
console.log('>>>>', action, args)
|
|
|
|
|
})
|
|
|
|
|
|
2015-12-31 07:00:18 +03:00
|
|
|
.parse(argv)
|
|
|
|
|
}]
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
|
* vim:set ts=4 sw=4 : */
|
|
|
|
|
return module })
|