cli now working, more cleanup and tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-05-28 18:31:42 +03:00
parent fcac70f7de
commit a6c80ddbc9
5 changed files with 34 additions and 38 deletions

View File

@ -1,3 +1,12 @@
/**********************************************************************
*
* This module is intended for quick and dirty tests and CSS experiments
*
* For production move the code from here to a more appropriate location
*
*
**********************************************************************/
body {
margin: 0;

View File

@ -109,6 +109,12 @@ module.CLI = core.ImageGridFeatures.Feature({
.version('0.0.1')
//.usage('[command] [options] ..')
.option('-v, --verbose', 'verbose mode', function(){
that.logger = {
emit: function(){ console.log.apply(console, arguments) }
}
})
// list features...
// XXX make this a core action... (???)
.option('lf, --list-features', 'list loaded features', function(){
@ -164,8 +170,16 @@ module.CLI = core.ImageGridFeatures.Feature({
.setup(that, ['viewer-minimal'])
})
.option('repl, --repl', 'start an ImageGrin REPL', function(){
//var repl = require('repl')
.option('repl, --repl', 'start an ImageGrid REPL', function(){
var repl = requirejs('repl')
// setup the global ns...
global.ig =
global.ImageGrid =
that
require('features/all')
global.ImageGridFeatures = core.ImageGridFeatures
//var ig = core.ImageGridFeatures
@ -176,30 +190,6 @@ module.CLI = core.ImageGridFeatures.Feature({
output: process.stdout,
ignoreUndefined: true,
/*
eval: function(str, context, filename, callback){
var res
var lst = str.split(/\s+/)
var cmd = lst.shift()
// we got an action...
if(cmd == 'var'){
eval(str, context, filename, callback)
// action...
} else if(cmd in ig){
ig[cmd].apply(ig, lst.map(eval))
// err
} else {
// XXX
}
callback(null, res)
},
*/
})
})
@ -217,7 +207,7 @@ module.CLI = core.ImageGridFeatures.Feature({
.arguments('<action> [args]')
.action(function(action, args){
// XXX
console.log('>>>>', action, args, !!that[action])
//console.log('>>>>', action, args, !!that[action])
that[action](args)
})

View File

@ -1301,7 +1301,7 @@ var FileSystemWriterActions = actions.Actions({
: this.hasOwnProperty('changes') ? this.changes
: null
return {
date: window.Date.timeStamp(),
date: Date.timeStamp(),
raw: json,
prepared: file.prepareIndex(json, changes),
}

View File

@ -174,7 +174,7 @@ function(elem, state_accessor, states, callback_a, callback_b){
var bool_action = (state_set.length == 2 && state_set[0] == 'none')
// XXX is this correct???
var args = args2array(arguments).slice(2)
var args = [].slice.call(arguments).slice(2)
// option number...
if(typeof(action) == typeof(1)){

View File

@ -83,6 +83,12 @@ Array.prototype.setCmp = function(other){
}
var args2array =
module.args2array =
Array.fromArgs =
function(args){ return [].slice.call(args) }
module.chainCmp = function(cmp_chain){
return function(a, b, get, data){
var res
@ -141,15 +147,6 @@ Object.defineProperty(Array.prototype, 'len', {
// convert JS arguments to Array...
var args2array =
module.args2array =
function(args){
//return Array.apply(null, args)
return [].slice.call(args)
}
// Quote a string and convert to RegExp to match self literally.
var quoteRegExp =
RegExp.quoteRegExp =