diff --git a/Viewer/features/cli.js b/Viewer/features/cli.js index f1510bed..148f4212 100755 --- a/Viewer/features/cli.js +++ b/Viewer/features/cli.js @@ -26,7 +26,9 @@ if(typeof(process) != 'undefined'){ var pathlib = requirejs('path') var argv = requirejs('lib/argv') var progress = requirejs('cli-progress') - var colors = requirejs('colors') } + var colors = requirejs('colors') + + var file = require('imagegrid/file') } @@ -53,14 +55,6 @@ var CLIActions = actions.Actions({ return this.getActionAttr(action, 'cli') }.bind(this)) }, - // XXX need introspection... - // ...some thing like .ls(path) to printout: - // - metadata (image count, dates, ...) - // - collections - // - ... - // XXX - - // XXX should this be here??? // ...move this to progress... // XXX we are missing some beats, is this because we do not let the @@ -265,7 +259,86 @@ var CLIActions = actions.Actions({ pathlib.dirname(nodeRequire.main.filename), 'e.js') ], { detached: true, }) } }], - /*/ XXX + + // Introspection... + // + /* XXX + cliInfo: ['- System/Show information about index in PATH', + {cli: { + name: '@info', + arg: 'PATH', + default: '.', + }}, + function(path, options={}){ + // XXX + }], + //*/ + // XXX revise naming... + // XXX how do we handle errors??? + cliListCollections: ['- System/List collections in index', + {cli: argv && argv.Parser({ + key: '@collections', + doc: 'List collection in index at PATH', + arg: 'PATH', + + '-version': undefined, + '-quiet': undefined, + + '-f': '-full', + '-full': { + doc: 'show full collection information', + type: 'bool', + }, + })}, + function(path, options={}){ + var that = this + + this.setupFeatures() + + path = path || options.value + path = util.normalizePath( + path ? + pathlib.resolve(process.cwd(), path) + : process.cwd()) + return this.loadIndex(path) + .then( + function(){ + for(var name of that.collection_order || []){ + // XXX revise output formatting... + options.full ? + console.log(that.collections[name].gid, name) + : console.log(name) } }, + function(err){ + // XXX how do we handle rejection??? + console.error('Can\'t find or load index at:', path) }) }], + // XXX handle errors... + cliListIndexes: ['- System/List indexes in PATH', + {cli: argv && argv.Parser({ + key: '@ls', + arg: 'PATH', + default: '.', + + '-version': undefined, + '-quiet': undefined, + + '-r': '-recursive', + '-recursive': { + doc: 'List nested/recursive indexes', + type: 'bool', + }, + })}, + function(path, options={}){ + file.listIndexes(path) + .on('end', function(paths){ + paths = + (options.recursive ? + paths + : file.skipNested(paths)) + .sortAs(paths) + for(var p of paths){ + console.log(p.replace(/.ImageGrid$/, '')) } }) }], + + /* XXX startWorker: ['- System/Start as worker', {cli: '-worker'}, function(){ @@ -424,41 +497,6 @@ var CLIActions = actions.Actions({ // XXX how do we handle rejection??? console.error('Can\'t find or load index at:', path) }) }], - // XXX revise naming... - // XXX how do we handle errors??? - cliListCollections: ['- System/List collections in index', - {cli: argv && argv.Parser({ - key: '@collections', - arg: 'PATH', - - '-f': '-full', - '-full': { - doc: 'show full collection information', - type: 'bool', - }, - })}, - function(path, options={}){ - var that = this - - this.setupFeatures() - - path = path || options.value - path = util.normalizePath( - path ? - pathlib.resolve(process.cwd(), path) - : process.cwd()) - return this.loadIndex(path) - .then( - function(){ - for(var name of that.collection_order || []){ - // XXX revise output formatting... - options.full ? - console.log(that.collections[name].gid, name) - : console.log(name) } }, - function(err){ - // XXX how do we handle rejection??? - console.error('Can\'t find or load index at:', path) }) }], - // Utility... (EXPERIMENTAL) // // XXX metadata caching and preview creation are not in sync, can diff --git a/Viewer/imagegrid/file.js b/Viewer/imagegrid/file.js index 0d384e89..c192c2e4 100755 --- a/Viewer/imagegrid/file.js +++ b/Viewer/imagegrid/file.js @@ -40,7 +40,9 @@ var INDEX_DIR = '.ImageGrid' // Skip nested indexes from tree... // -var skipNested = function(paths, index_dir, logger){ +var skipNested = +module.skipNested = +function(paths, index_dir, logger){ logger = logger && logger.push('Skipping nested') paths = paths