minor tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-12-10 06:44:47 +03:00
parent afef0a36d4
commit 7db2efd948
3 changed files with 56 additions and 36 deletions

View File

@ -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

View File

@ -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: <path>,
'include-virtual': <bool>,
'clean-target': <bool>,
// NOTE: file extension is added automatically...
// NOTE: see .formatImageName(..) for format docs...
'preview-name-pattern': <str>,
'export-mode': 'copy best match' | 'resize',
'preview-size': <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')) ?

View File

@ -15,7 +15,7 @@
// - browser + requirejs + http*
var VERSION = '4.0.0a'
console.log(VERSION)
//console.log(VERSION)
module.version = VERSION