mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +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 pathlib = requirejs('path') | ||||||
| 	var argv = requirejs('lib/argv') | 	var argv = requirejs('lib/argv') | ||||||
| 	var progress = requirejs('cli-progress') | 	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)) }, | 				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???
 | 	// 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 
 | ||||||
| @ -265,7 +259,86 @@ var CLIActions = actions.Actions({ | |||||||
| 							pathlib.dirname(nodeRequire.main.filename),  | 							pathlib.dirname(nodeRequire.main.filename),  | ||||||
| 							'e.js') ], | 							'e.js') ], | ||||||
| 						{ detached: true, }) } }], | 						{ 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', | 	startWorker: ['- System/Start as worker', | ||||||
| 		{cli: '-worker'}, | 		{cli: '-worker'}, | ||||||
| 		function(){ | 		function(){ | ||||||
| @ -424,41 +497,6 @@ var CLIActions = actions.Actions({ | |||||||
| 						// XXX how do we handle rejection???
 | 						// XXX how do we handle rejection???
 | ||||||
| 						console.error('Can\'t find or load index at:', path) }) }], | 						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)
 | 	// Utility... (EXPERIMENTAL)
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// XXX metadata caching and preview creation are not in sync, can 
 | 	// XXX metadata caching and preview creation are not in sync, can 
 | ||||||
|  | |||||||
| @ -40,7 +40,9 @@ var INDEX_DIR = '.ImageGrid' | |||||||
| 
 | 
 | ||||||
| // Skip nested indexes from tree...
 | // 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') | 	logger = logger && logger.push('Skipping nested') | ||||||
| 
 | 
 | ||||||
| 	paths = paths | 	paths = paths | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user