mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
added "ig ls" action...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
321a434554
commit
04936a20e7
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user