From e020cc64e1988669a919a00bc7262572839ecf86 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 10 Dec 2020 21:59:15 +0300 Subject: [PATCH] more tweaking of cli... Signed-off-by: Alex A. Naanou --- Viewer/features/cli.js | 29 +++++++++----- Viewer/features/filesystem.js | 71 ++++++++++++++++------------------- Viewer/package-lock.json | 14 +++---- Viewer/package.json | 2 +- 4 files changed, 60 insertions(+), 56 deletions(-) diff --git a/Viewer/features/cli.js b/Viewer/features/cli.js index 76deaefa..4ad20a8b 100755 --- a/Viewer/features/cli.js +++ b/Viewer/features/cli.js @@ -280,8 +280,6 @@ var CLIActions = actions.Actions({ {cli: argv && argv.Parser({ key: '@export', - //usage: '$SCRIPTNAME to=PATH [OPTIONS]', - // help... '-help-pattern': { doc: 'Show image filename pattern info and exit', @@ -296,39 +294,51 @@ var CLIActions = actions.Actions({ '@from': { doc: 'Source path', arg: 'PATH | from', - default: '.', }, + default: '.', + valueRequired: true, }, '@to': { doc: 'Destination path', arg: 'PATH | path', required: true, valueRequired: true, }, - // options... + // bool options... // XXX these should get defaults from .config '-include-virtual': { doc: 'Include virtual blocks', - arg: 'BOOL | include-virtual', + arg: '| include-virtual', type: 'bool', + value: true, default: true, }, '-clean-target': { doc: 'Cleanup target before export (backup)', - arg: 'BOOL | clean-target', + arg: '| clean-target', type: 'bool', + value: true, default: true, }, + '-no-*': { + doc: 'Negate boolean option value', + handler: function(rest, key, value, ...args){ + rest.unshift(key.replace(/^-?-no/, '') +'=false') } }, + + // options... '-image-name': { doc: 'Image name pattern', arg: 'PATTERN | preview-name-pattern', - default: '%(fav)l%n%(-%c)c', }, + default: '%(fav)l%n%(-%c)c', + valueRequired: true, }, // XXX get values automatically... '-mode': { doc: 'Export mode, can be "resize" or "copy best match"', arg: 'MODE | export-mode', //default: 'copy best match', - default: 'resize', }, + default: 'resize', + valueRequired: true, }, '-image-size': { doc: 'Output image size', arg: 'SIZE | preview-size', - default: 1000, }, + default: 1000, + valueRequired: true, }, })}, function(path, options={}){ var that = this @@ -343,7 +353,6 @@ var CLIActions = actions.Actions({ .then( function(){ return that.exportImages(options) }, - // XXX for some reason we still get an error up the call stack... function(err){ console.error('Can\'t find or load index at:', path) }) }], diff --git a/Viewer/features/filesystem.js b/Viewer/features/filesystem.js index 6db226a2..86129b5f 100755 --- a/Viewer/features/filesystem.js +++ b/Viewer/features/filesystem.js @@ -262,43 +262,35 @@ var FileSystemLoaderActions = actions.Actions({ // NOTE: when passed no path this will not do anything... // NOTE: this will add a .from field to .location, this will indicate // the date starting from which saves are loaded. - // - // XXX look inside... loadIndex: ['- File/Load index', function(path, from_date, logger){ var that = this var index_dir = util.normalizePath(this.config['index-dir']) - // XXX get a logger... + logger = logger || this.logger logger = logger && logger.push('Load') if(path == null){ - return - } + logger && logger.emit('error: no path given') + return Promise.reject('no path given') } path = util.normalizePath(path) if(from_date && from_date.emit != null){ logger = from_date from_date = null } - // XXX make this load incrementally (i.e. and EventEmitter - // a-la glob).... - //file.loadIndex(path, this.config['index-dir'], logger) return file.loadIndex(path, index_dir, from_date, logger) .then(function(res){ var force_full_save = false // skip nested paths... - // // XXX make this optional... - // XXX this is best done BEFORE we load all the - // indexes, e.g. in .loadIndex(..) var skipped = new Set() var paths = Object.keys(res) // no indexes found... if(paths.length == 0){ - logger && logger.emit('error: no index at', path) - return Promise.reject('no index at: '+ path) } + logger && logger.emit('error: no index in', path) + return Promise.reject('no index in: '+ path) } paths .forEach(function(p){ // already removed... @@ -364,11 +356,9 @@ var FileSystemLoaderActions = actions.Actions({ // merge... index.data.join(part.data) - index.images.join(part.images) - } + index.images.join(part.images) } - loaded.push(k) - } + loaded.push(k) } logger && logger.emit('load index', index) @@ -553,9 +543,7 @@ var FileSystemLoaderActions = actions.Actions({ }) } // pass on the result... - resolve(imgs) - }) - }) + resolve(imgs) }) }) // load previews if they exist... .then(function(imgs){ var index_dir = that.config['index-dir'] @@ -997,34 +985,41 @@ module.FileSystemLoader = core.ImageGridFeatures.Feature({ ['loadImages', function(res){ var that = this - res.then(function(){ - that.markChanged('all') }) }], + res.then( + function(){ + that.markChanged('all') }, + function(){}) }], // add new images to changes... ['loadNewImages', function(res){ var that = this - res.then(function(imgs){ - imgs - && imgs.length > 0 - && that - .markChanged('data') - .markChanged('images', imgs.keys()) }) - }], + res.then( + function(imgs){ + imgs + && imgs.length > 0 + && that + .markChanged('data') + .markChanged('images', imgs.keys()) }, + function(){}) }], ['checkIndex', function(res){ var that = this - res.then(function(gids){ - gids.length > 0 - && that.markChanged('images', gids) }) }], + res.then( + function(gids){ + gids.length > 0 + && that.markChanged('images', gids) }, + function(){}) }], ['removeMissingImages', function(res){ var that = this - res.then(function(gids){ - gids.length > 0 - && that - .markChanged('data') - .markChanged('images') - .reload(true) }) }], + res.then( + function(gids){ + gids.length > 0 + && that + .markChanged('data') + .markChanged('images') + .reload(true) }, + function(){}) }], ], }) diff --git a/Viewer/package-lock.json b/Viewer/package-lock.json index ee6ca147..b5a144be 100755 --- a/Viewer/package-lock.json +++ b/Viewer/package-lock.json @@ -1,6 +1,6 @@ { "name": "ImageGrid.Viewer.g4", - "version": "4.0.0a", + "version": "4.0.0-a", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1124,9 +1124,9 @@ } }, "ig-argv": { - "version": "2.15.7", - "resolved": "https://registry.npmjs.org/ig-argv/-/ig-argv-2.15.7.tgz", - "integrity": "sha512-o5SpXe6r/mv8TuwMiOr3EmQz2bVmCQ2h9bd4hM9rIJN3LtPh8mtprqC30Yc/+JMtaRH0nkdblGlZKbOJz00wBA==", + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/ig-argv/-/ig-argv-2.16.0.tgz", + "integrity": "sha512-lWgUthK4CBpYJlaFaRmfaCVlZW4u4n/9QZAcTnutDAe5wT5UJ6nD+X/OJLgqU1suLP2H5OThGJtdDBNqwEPGOA==", "requires": { "ig-object": "^5.2.6" } @@ -1183,9 +1183,9 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz", + "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==" }, "is-arrayish": { "version": "0.3.2", diff --git a/Viewer/package.json b/Viewer/package.json index 4a4abb60..f6f0e0ae 100755 --- a/Viewer/package.json +++ b/Viewer/package.json @@ -31,7 +31,7 @@ "glob": "^7.1.6", "guarantee-events": "^1.0.0", "ig-actions": "^3.24.22", - "ig-argv": "^2.15.7", + "ig-argv": "^2.16.0", "ig-features": "^3.4.2", "ig-object": "^5.4.12", "ig-types": "^5.0.40",