diff --git a/Viewer/features/cli.js b/Viewer/features/cli.js index 61d0dff4..258d4398 100755 --- a/Viewer/features/cli.js +++ b/Viewer/features/cli.js @@ -7,6 +7,7 @@ (function(require){ var module={} // make module AMD/node compatible... /*********************************************************************/ +var object = require('lib/object') var util = require('lib/util') var actions = require('lib/actions') var features = require('lib/features') @@ -294,10 +295,13 @@ var CLIActions = actions.Actions({ }], //*/ + // XXX test... + // XXX report that can't find an index... cliExportImages: ['- System/Export images', - {cli: argv.Parser({ + {cli: argv && argv.Parser({ key: '@export', + // help... '-help-pattern': { doc: 'Show image filename pattern info and exit', priority: 89, @@ -307,16 +311,18 @@ var CLIActions = actions.Actions({ '-version': undefined, '-quiet': undefined, + // commands... '@from': { doc: 'Source path', - arg: 'FROM | from', + arg: 'PATH | from', default: '.', }, '@to': { doc: 'Destination path', - arg: 'TO | path', + arg: 'PATH | path', required: true, valueRequired: true, }, + // options... // XXX these should get defaults from .config '-include-virtual': { doc: 'Include virtual blocks', @@ -328,28 +334,26 @@ var CLIActions = actions.Actions({ arg: 'BOOL | clean-target', type: 'bool', default: true, }, - // XXX add tip to get doc... - // .formatImageName(..) -- format docs... '-image-name': { doc: 'Image name pattern', arg: 'PATTERN | preview-name-pattern', default: '%(fav)l%n%(-%c)c', }, + // XXX get values automatically... '-mode': { - doc: 'Export mode', + doc: 'Export mode, can be "resize" or "copy best match"', arg: 'MODE | export-mode', //default: 'copy best match', default: 'resize', }, - // XXX add help on possible values... '-image-size': { doc: 'Output image size', arg: 'SIZE | preview-size', default: 1000, }, })}, - function(){ - console.log('EXPORT', ...arguments) - // XXX load from... - // XXX export to... - }], + function(path, options={}){ + var that = this + return this.loadIndex(path || options.path || '.') + .then(function(){ + return that.exportImages(options) }) }], // Utility... (EXPERIMENTAL) // @@ -413,8 +417,8 @@ var CLIActions = actions.Actions({ .then(function(){ if(index.makePreviews){ return Promise.all([ - // NOTE: this is already running after .loadImages(..) - //index.cacheMetadata('all'), + // NOTE: no need to call .cacheMetadata(..) as + // it is already running after .loadImages(..) index.makePreviews('all') ])} }) .then(function(){ return index diff --git a/Viewer/features/filesystem.js b/Viewer/features/filesystem.js index ebd6991d..a31ebf21 100755 --- a/Viewer/features/filesystem.js +++ b/Viewer/features/filesystem.js @@ -1797,29 +1797,29 @@ var FileSystemWriterActions = actions.Actions({ core.doc` Filename patterns: - %n - name without extension + %n - name without extension - %gid - full image gid - %g - short gid + %gid - full image gid + %g - short gid - %i - image index in ribbon - %I - global image index + %i - image index in ribbon + %I - global image index %r - ribbon number %R - ribbon number counting from the bottom - - %t - total number of images in ribbon - %T - total number of images - - %(...)m - add text in braces if image marked - %(...)b - add text in braces if image is bookmark - - %(...)C - add text in braces if there are name conflicts. + + %t - total number of images in ribbon + %T - total number of images + + %(...)m - add text in braces if image marked + %(...)b - add text in braces if image is bookmark + + %(...)C - add text in braces if there are name conflicts. NOTE: this will be added to all images. - %(...)c - add text in braces if there are name conflicts + %(...)c - add text in braces if there are name conflicts present, but only if the current image has a conflicting name. - %c - number in set of conflicting names (default: 0). + %c - number in set of conflicting names (default: 0). NOTE: this is not stable and can change depending on image order. @@ -2060,7 +2060,7 @@ var FileSystemWriterActions = actions.Actions({ return index }) }], // XXX add name conflict resolution strategies (pattern)... - // ...use the same strategy as for .exportDirs(..) + // ...use the same strategy as for .exportImages(..) // XXX ways to treat a collection: // - crop data // - independent index @@ -2355,6 +2355,7 @@ var FileSystemWriterActions = actions.Actions({ return Promise.all(queue) }], + // XXX ASAP rename to exportImages(..) // XXX ASAP test settings['export-mode'] = 'copy best match' // XXX might also be good to save/load the export options to .ImageGrid-export.json // XXX resolve env variables in path... (???) @@ -2364,16 +2365,31 @@ var FileSystemWriterActions = actions.Actions({ // XXX use tasks... // XXX check global index ('%I') in crop... // XXX make clean_target more error tolerant... - exportDirs: ['- File/Export/Export ribbons as directories', + exportImages: ['- File/Export/Export ribbons as directories', core.doc`Export ribbons as directories - .exportDirs(path) - .exportDirs(settings) + .exportImages(path) + .exportImages(settings) + settings format: { + path: , + + 'include-virtual': , + + 'clean-target': , + + // NOTE: file extension is added automatically... + // NOTE: see .formatImageName(..) for format docs... + 'preview-name-pattern': , + + 'export-mode': 'copy best match' | 'resize', + + 'preview-size': , } + NOTE: see .formatImageName(..) for pattern syntax details. `, function(path, pattern, level_dir, size, include_virtual, clean_target_dir, logger){ @@ -2610,7 +2626,7 @@ var FileSystemWriterUIActions = actions.Actions({ }, 'Images only': { alias: 'images', - action: 'exportDirs', + action: 'exportImages', data: [ //'name', 'pattern', @@ -3459,7 +3475,7 @@ module.FileSystemWriterUI = core.ImageGridFeatures.Feature({ // update export history... [[ 'exportIndex', - 'exportDirs', + 'exportImages', ], function(_, settings){ this.exportHistoryPush( (!settings || typeof(settings) == typeof('str')) ? diff --git a/Viewer/version.js b/Viewer/version.js index 9b90736e..e149e4ac 100644 --- a/Viewer/version.js +++ b/Viewer/version.js @@ -15,7 +15,7 @@ // - browser + requirejs + http* var VERSION = '4.0.0a' -console.log(VERSION) +//console.log(VERSION) module.version = VERSION