mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
working on CLI...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
fbadbfe55e
commit
afef0a36d4
@ -56,11 +56,21 @@ if(typeof(process) != 'undefined'){
|
|||||||
|
|
||||||
var CLIActions = actions.Actions({
|
var CLIActions = actions.Actions({
|
||||||
|
|
||||||
|
help: ['- System/Show action help',
|
||||||
|
function(...actions){
|
||||||
|
Object.entries(this.getDoc(actions))
|
||||||
|
.forEach(function([action, [s, l]]){
|
||||||
|
console.log(l)
|
||||||
|
console.log('')
|
||||||
|
}) }],
|
||||||
|
|
||||||
|
|
||||||
get cliActions(){
|
get cliActions(){
|
||||||
return this.actions
|
return this.actions
|
||||||
.filter(function(action){
|
.filter(function(action){
|
||||||
return this.getActionAttr(action, 'cli') }.bind(this)) },
|
return this.getActionAttr(action, 'cli') }.bind(this)) },
|
||||||
|
|
||||||
|
|
||||||
// XXX should this be here???
|
// XXX should this be here???
|
||||||
// ...move this to progress...
|
// ...move this to progress...
|
||||||
// XXX we are missing some beats, is this because we do not let the
|
// XXX we are missing some beats, is this because we do not let the
|
||||||
@ -199,6 +209,9 @@ var CLIActions = actions.Actions({
|
|||||||
global.ImageGrid =
|
global.ImageGrid =
|
||||||
this
|
this
|
||||||
|
|
||||||
|
global.help = function(...actions){
|
||||||
|
global.ig.help(...actions) }
|
||||||
|
|
||||||
require('features/all')
|
require('features/all')
|
||||||
global.ImageGridFeatures = core.ImageGridFeatures
|
global.ImageGridFeatures = core.ImageGridFeatures
|
||||||
|
|
||||||
@ -247,11 +260,6 @@ var CLIActions = actions.Actions({
|
|||||||
// Actions...
|
// Actions...
|
||||||
//
|
//
|
||||||
/*/ XXX
|
/*/ XXX
|
||||||
cliIndexInit: ['- System/Initialize and create index',
|
|
||||||
{cli: '@init'},
|
|
||||||
function(){
|
|
||||||
// XXX
|
|
||||||
}],
|
|
||||||
// XXX this should be a nested parser...
|
// XXX this should be a nested parser...
|
||||||
// args:
|
// args:
|
||||||
// from=PATH
|
// from=PATH
|
||||||
@ -289,19 +297,58 @@ var CLIActions = actions.Actions({
|
|||||||
cliExportImages: ['- System/Export images',
|
cliExportImages: ['- System/Export images',
|
||||||
{cli: argv.Parser({
|
{cli: argv.Parser({
|
||||||
key: '@export',
|
key: '@export',
|
||||||
arg: 'TO',
|
|
||||||
|
|
||||||
// XXX get the export options -- see export UI...
|
'-help-pattern': {
|
||||||
|
doc: 'Show image filename pattern info and exit',
|
||||||
|
priority: 89,
|
||||||
|
handler: function(){
|
||||||
|
this.parent.context.help('formatImageName')
|
||||||
|
return argv.STOP } },
|
||||||
|
'-version': undefined,
|
||||||
|
'-quiet': undefined,
|
||||||
|
|
||||||
'@from': {
|
'@from': {
|
||||||
doc: 'Source path',
|
doc: 'Source path',
|
||||||
arg: 'FROM'},
|
arg: 'FROM | from',
|
||||||
|
default: '.', },
|
||||||
'@to': {
|
'@to': {
|
||||||
doc: 'Destination path',
|
doc: 'Destination path',
|
||||||
arg: 'TO'},
|
arg: 'TO | path',
|
||||||
|
required: true,
|
||||||
|
valueRequired: true, },
|
||||||
|
|
||||||
|
// XXX these should get defaults from .config
|
||||||
|
'-include-virtual': {
|
||||||
|
doc: 'Include virtual blocks',
|
||||||
|
arg: 'BOOL | include-virtual',
|
||||||
|
type: 'bool',
|
||||||
|
default: true, },
|
||||||
|
'-clean-target': {
|
||||||
|
doc: 'Cleanup target before export (backup)',
|
||||||
|
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', },
|
||||||
|
'-mode': {
|
||||||
|
doc: 'Export mode',
|
||||||
|
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(){
|
function(){
|
||||||
// XXX
|
console.log('EXPORT', ...arguments)
|
||||||
|
// XXX load from...
|
||||||
|
// XXX export to...
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// Utility... (EXPERIMENTAL)
|
// Utility... (EXPERIMENTAL)
|
||||||
@ -312,22 +359,53 @@ var CLIActions = actions.Actions({
|
|||||||
// XXX should we support creating multiple indexes at the same time???
|
// XXX should we support creating multiple indexes at the same time???
|
||||||
// XXX this is reletively generic, might be useful globally...
|
// XXX this is reletively generic, might be useful globally...
|
||||||
// XXX should we use a clean index or do this in-place???
|
// XXX should we use a clean index or do this in-place???
|
||||||
makeIndex: ['- System/Make index',
|
// XXX add ability to disable sort...
|
||||||
{cli: {
|
initIndex: ['- System/Make index',
|
||||||
name: '@make',
|
core.doc`
|
||||||
arg: 'PATH',
|
|
||||||
valueRequired: true,
|
|
||||||
}},
|
|
||||||
function(path){
|
|
||||||
var that = this
|
|
||||||
|
|
||||||
|
Create index in current directory
|
||||||
|
.initIndex()
|
||||||
|
.initIndex('create')
|
||||||
|
-> promise
|
||||||
|
|
||||||
|
Create index in path...
|
||||||
|
,initIndex(path)
|
||||||
|
.initIndex('create', path)
|
||||||
|
-> promise
|
||||||
|
|
||||||
|
|
||||||
|
Update index in current directory
|
||||||
|
.initIndex('update')
|
||||||
|
-> promise
|
||||||
|
|
||||||
|
Update index in path...
|
||||||
|
.initIndex('update', path)
|
||||||
|
-> promise
|
||||||
|
|
||||||
|
`,
|
||||||
|
{cli: {
|
||||||
|
name: '@init',
|
||||||
|
arg: 'PATH',
|
||||||
|
//valueRequired: true,
|
||||||
|
}},
|
||||||
|
function(path, options){
|
||||||
|
// get mode...
|
||||||
|
if(path == 'create' || path == 'update'){
|
||||||
|
var [mode, path, options] = arguments }
|
||||||
|
mode = mode || 'create'
|
||||||
|
// normalize path...
|
||||||
path = util.normalizePath(
|
path = util.normalizePath(
|
||||||
pathlib.resolve(process.cwd(), path))
|
path ?
|
||||||
|
pathlib.resolve(process.cwd(), path)
|
||||||
|
: process.cwd())
|
||||||
|
options = options || {}
|
||||||
|
|
||||||
// XXX should we use a clean index or do this in-place???
|
// XXX should we use a clean index or do this in-place???
|
||||||
//var index = this.constructor(..)
|
//var index = this.constructor(..)
|
||||||
var index = this
|
var index = this
|
||||||
return index.loadImages(path)
|
return (mode == 'create' ?
|
||||||
|
index.loadImages(path)
|
||||||
|
: index.loadNewImages(path))
|
||||||
// save base index...
|
// save base index...
|
||||||
.then(function(){
|
.then(function(){
|
||||||
return index.saveIndex() })
|
return index.saveIndex() })
|
||||||
@ -342,6 +420,16 @@ var CLIActions = actions.Actions({
|
|||||||
return index
|
return index
|
||||||
.sortImages()
|
.sortImages()
|
||||||
.saveIndex() }) }],
|
.saveIndex() }) }],
|
||||||
|
// XXX does not work yet...
|
||||||
|
updateIndex: ['- System/Update index',
|
||||||
|
{cli: {
|
||||||
|
name: '@update',
|
||||||
|
arg: 'PATH',
|
||||||
|
}},
|
||||||
|
'initIndex: "update" ...'],
|
||||||
|
cleanIndex: ['- System/',
|
||||||
|
{},
|
||||||
|
function(path, options){}],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -380,6 +468,8 @@ module.CLI = core.ImageGridFeatures.Feature({
|
|||||||
var pkg = nodeRequire('./package.json')
|
var pkg = nodeRequire('./package.json')
|
||||||
|
|
||||||
argv.Parser({
|
argv.Parser({
|
||||||
|
context: this,
|
||||||
|
|
||||||
// XXX argv.js is not picking these up because
|
// XXX argv.js is not picking these up because
|
||||||
// of the require(..) mixup...
|
// of the require(..) mixup...
|
||||||
author: pkg.author,
|
author: pkg.author,
|
||||||
@ -418,9 +508,8 @@ module.CLI = core.ImageGridFeatures.Feature({
|
|||||||
res[name] = cmd instanceof argv.Parser ?
|
res[name] = cmd instanceof argv.Parser ?
|
||||||
cmd
|
cmd
|
||||||
// XXX need to call the action...
|
// XXX need to call the action...
|
||||||
.then(function(){
|
.then(function(unhandled, value, rest){
|
||||||
// XXX
|
that[action](value, this) })
|
||||||
})
|
|
||||||
: {
|
: {
|
||||||
doc: (that.getActionAttr(action, 'doc') || '')
|
doc: (that.getActionAttr(action, 'doc') || '')
|
||||||
.split(/[\\\/]/g).pop(),
|
.split(/[\\\/]/g).pop(),
|
||||||
|
|||||||
@ -1793,7 +1793,7 @@ var FileSystemWriterActions = actions.Actions({
|
|||||||
// ...need a better name...
|
// ...need a better name...
|
||||||
// XXX add tags/keywords...
|
// XXX add tags/keywords...
|
||||||
// %(tag|...)k - if image is tagged with tag add text
|
// %(tag|...)k - if image is tagged with tag add text
|
||||||
formatImageName: ['- File/',
|
formatImageName: ['- File/Format image filename',
|
||||||
core.doc`
|
core.doc`
|
||||||
|
|
||||||
Filename patterns:
|
Filename patterns:
|
||||||
@ -2370,6 +2370,10 @@ var FileSystemWriterActions = actions.Actions({
|
|||||||
.exportDirs(path)
|
.exportDirs(path)
|
||||||
.exportDirs(settings)
|
.exportDirs(settings)
|
||||||
|
|
||||||
|
settings format:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NOTE: see .formatImageName(..) for pattern syntax details.
|
NOTE: see .formatImageName(..) for pattern syntax details.
|
||||||
`,
|
`,
|
||||||
function(path, pattern, level_dir, size, include_virtual, clean_target_dir, logger){
|
function(path, pattern, level_dir, size, include_virtual, clean_target_dir, logger){
|
||||||
|
|||||||
12
Viewer/package-lock.json
generated
12
Viewer/package-lock.json
generated
@ -1116,17 +1116,17 @@
|
|||||||
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
|
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
|
||||||
},
|
},
|
||||||
"ig-actions": {
|
"ig-actions": {
|
||||||
"version": "3.24.21",
|
"version": "3.24.22",
|
||||||
"resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.21.tgz",
|
"resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.22.tgz",
|
||||||
"integrity": "sha512-fPdi3BEKxKDVcYiO9+Utg3NCqCATQUXPU+wIbdAsA4+AT8zx1EPKZl+vLUn3V0VPKAh9O4bvlWxqNn4GNjC2fQ==",
|
"integrity": "sha512-aPTGlyAjecNS6eBzldLjIW0oDHHzglQYHk3eptU78OOiNkG0kTINmUAGaFjHswX0G9TftVQ4JGf+UxVQkqowAg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ig-object": "^5.4.12"
|
"ig-object": "^5.4.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ig-argv": {
|
"ig-argv": {
|
||||||
"version": "2.15.1",
|
"version": "2.15.6",
|
||||||
"resolved": "https://registry.npmjs.org/ig-argv/-/ig-argv-2.15.1.tgz",
|
"resolved": "https://registry.npmjs.org/ig-argv/-/ig-argv-2.15.6.tgz",
|
||||||
"integrity": "sha512-BJ0j6aoIkWVjXEVZ/A+U4FTn4DYqthZ5W0XwOQYkeuR85FXVZuAFo1Ugdz6DJp3J7WrdpVRXQpIFDRobB84eZw==",
|
"integrity": "sha512-jQeDbiafqDPKxymYdC81msNEUPEbj5Ocvh4QvucZNFJ0m2DTMxBI4tMgg7IAJJWxlMke1J0U/p7Nhs8m2RStcw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ig-object": "^5.2.6"
|
"ig-object": "^5.2.6"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,8 +30,8 @@
|
|||||||
"generic-walk": "^1.4.0",
|
"generic-walk": "^1.4.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"guarantee-events": "^1.0.0",
|
"guarantee-events": "^1.0.0",
|
||||||
"ig-actions": "^3.24.21",
|
"ig-actions": "^3.24.22",
|
||||||
"ig-argv": "^2.15.1",
|
"ig-argv": "^2.15.6",
|
||||||
"ig-features": "^3.4.2",
|
"ig-features": "^3.4.2",
|
||||||
"ig-object": "^5.4.12",
|
"ig-object": "^5.4.12",
|
||||||
"ig-types": "^5.0.40",
|
"ig-types": "^5.0.40",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user