mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 11:20:09 +00:00 
			
		
		
		
	cleanup and tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									04420b7a3b
								
							
						
					
					
						commit
						fb7e4ac063
					
				| @ -104,13 +104,22 @@ var CLIActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 			var container = settings.__multi_bar =  | 			var container = settings.__multi_bar =  | ||||||
| 				settings.__multi_bar  | 				settings.__multi_bar  | ||||||
| 					|| new progress.MultiBar({ | 					|| (new progress.MultiBar({ | ||||||
| 						// XXX make this simpler...
 | 								// XXX make this simpler...
 | ||||||
| 						format: '{text}  {bar} {percentage}% ' | 								format: '{text}  {bar} {percentage}% ' | ||||||
| 							+'| ETA: {eta_formatted} | {value}/{total}', | 									+'| ETA: {eta_formatted} | {value}/{total}', | ||||||
| 						autopadding: true, | 								autopadding: true, | ||||||
| 					}, | 								stopOnComplete: true, | ||||||
| 					progress.Presets.rect) | 								forceRedraw: true, | ||||||
|  | 							}, | ||||||
|  | 							progress.Presets.rect) | ||||||
|  | 						// prepare for printing stuff...
 | ||||||
|  | 						.run(function(){ | ||||||
|  | 							this.on('redraw-pre', function(){ | ||||||
|  | 								// XXX need to clear the line -- need to get term-width....
 | ||||||
|  | 								// XXX this requires a full draw (forceRedraw: true)...
 | ||||||
|  | 								console.log('moo'.padEnd(process.stdout.columns)) | ||||||
|  | 							}) })) | ||||||
| 			var bar = state.bar =  | 			var bar = state.bar =  | ||||||
| 				state.bar || container.create(0, 0, {text: text.padEnd(l)}) | 				state.bar || container.create(0, 0, {text: text.padEnd(l)}) | ||||||
| 
 | 
 | ||||||
| @ -172,12 +181,14 @@ var CLIActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 	// Startup commands...
 | ||||||
|  | 	//
 | ||||||
| 	startREPL: ['- System/Start CLI interpreter', | 	startREPL: ['- System/Start CLI interpreter', | ||||||
| 		{cli: '@repl'}, | 		{cli: '@repl'}, | ||||||
| 		function(){ | 		function(){ | ||||||
| 			var repl = nodeRequire('repl') | 			var repl = nodeRequire('repl') | ||||||
| 
 | 
 | ||||||
| 			this._keep_running = true | 			this.__keep_running = true | ||||||
| 
 | 
 | ||||||
| 			// setup the global ns...
 | 			// setup the global ns...
 | ||||||
| 			global.ig = | 			global.ig = | ||||||
| @ -203,12 +214,25 @@ var CLIActions = actions.Actions({ | |||||||
| 				.on('exit', function(){ | 				.on('exit', function(){ | ||||||
| 					//ig.stop() 
 | 					//ig.stop() 
 | ||||||
| 					process.exit() }) }], | 					process.exit() }) }], | ||||||
| 	// XXX
 | 	// XXX this is the wrong strategy...
 | ||||||
|  | 	// XXX move this to a feature that requires electron...
 | ||||||
|  | 	// 		...and move electron to an optional dependency...
 | ||||||
| 	startGUI: ['- System/Start viewer GUI', | 	startGUI: ['- System/Start viewer GUI', | ||||||
| 		{cli: '@gui'}, | 		{cli: '@gui'}, | ||||||
| 		function(){ | 		function(){ | ||||||
| 			// XXX
 | 			requirejs('child_process') | ||||||
| 		}], | 				.spawn(requirejs('electron'), [ | ||||||
|  | 						pathlib.join( | ||||||
|  | 							pathlib.dirname(nodeRequire.main.filename),  | ||||||
|  | 							'e.js') ]) | ||||||
|  | 				// XXX need to stop the process iff nothing 
 | ||||||
|  | 				// 		else is running, like repl... 
 | ||||||
|  | 				// XXX feels hackish...
 | ||||||
|  | 				.on('exit', function(){ | ||||||
|  | 					(!global.ig | ||||||
|  | 							|| global.ig.isStopped()) | ||||||
|  | 						&& process.exit() }) | ||||||
|  | 			this.__keep_running = true }], | ||||||
| 	// XXX
 | 	// XXX
 | ||||||
| 	startWorker: ['- System/Start as worker', | 	startWorker: ['- System/Start as worker', | ||||||
| 		{cli: '-worker'}, | 		{cli: '-worker'}, | ||||||
| @ -216,6 +240,62 @@ var CLIActions = actions.Actions({ | |||||||
| 			// XXX
 | 			// XXX
 | ||||||
| 		}], | 		}], | ||||||
| 
 | 
 | ||||||
|  | 	// Actions...
 | ||||||
|  | 	//
 | ||||||
|  | 	/*/ XXX | ||||||
|  | 	cliIndexInit: ['- System/Initialize and create index', | ||||||
|  | 		{cli: '@init'}, | ||||||
|  | 		function(){ | ||||||
|  | 			// XXX
 | ||||||
|  | 		}], | ||||||
|  | 	// XXX this should be a nested parser...
 | ||||||
|  | 	// 		args:
 | ||||||
|  | 	// 			from=PATH
 | ||||||
|  | 	// 			to=PATH
 | ||||||
|  | 	// 			...
 | ||||||
|  | 	cliExportIindex: ['- System/Clone index', | ||||||
|  | 		{cli: { | ||||||
|  | 			name: '@clone', | ||||||
|  | 			arg: 'PATH', | ||||||
|  | 			valueRequired: true, | ||||||
|  | 		}}, | ||||||
|  | 		function(){ | ||||||
|  | 			// XXX
 | ||||||
|  | 		}], | ||||||
|  | 	cliPullChanges: ['- System/Pull changes', | ||||||
|  | 		{cli: { | ||||||
|  | 			name: '@pull', | ||||||
|  | 			arg: 'PATH', | ||||||
|  | 			valueRequired: true, | ||||||
|  | 		}}, | ||||||
|  | 		function(){ | ||||||
|  | 			// XXX
 | ||||||
|  | 		}], | ||||||
|  | 	cliPushChanges: ['- System/Push changes', | ||||||
|  | 		{cli: { | ||||||
|  | 			name: '@push', | ||||||
|  | 			arg: 'PATH', | ||||||
|  | 			valueRequired: true, | ||||||
|  | 		}}, | ||||||
|  | 		function(){ | ||||||
|  | 			// XXX
 | ||||||
|  | 		}], | ||||||
|  | 	//*/
 | ||||||
|  | 
 | ||||||
|  | 	cliExportImages: ['- System/Export images', | ||||||
|  | 		{cli: argv.Parser({ | ||||||
|  | 			key: '@export', | ||||||
|  | 			arg: 'PATH', | ||||||
|  | 
 | ||||||
|  | 			// XXX
 | ||||||
|  | 
 | ||||||
|  | 		})}, | ||||||
|  | 		function(){ | ||||||
|  | 			// XXX
 | ||||||
|  | 		}], | ||||||
|  | 
 | ||||||
|  | 	// Utility... (EXPERIMENTAL)
 | ||||||
|  | 	//
 | ||||||
| 	// XXX metadata caching and preview creation are not in sync, can 
 | 	// XXX metadata caching and preview creation are not in sync, can 
 | ||||||
| 	// 		this be a problem???
 | 	// 		this be a problem???
 | ||||||
| 	// 		...if not, add a note...
 | 	// 		...if not, add a note...
 | ||||||
| @ -282,6 +362,7 @@ module.CLI = core.ImageGridFeatures.Feature({ | |||||||
| 					&& (this.logger.quiet = true) }], | 					&& (this.logger.quiet = true) }], | ||||||
| 
 | 
 | ||||||
| 		// handle args...
 | 		// handle args...
 | ||||||
|  | 		// XXX
 | ||||||
| 		['ready', | 		['ready', | ||||||
| 			function(){ | 			function(){ | ||||||
| 				var that = this | 				var that = this | ||||||
| @ -317,17 +398,23 @@ module.CLI = core.ImageGridFeatures.Feature({ | |||||||
| 									var cmd = {name} } | 									var cmd = {name} } | ||||||
| 								var name = name === true ?  | 								var name = name === true ?  | ||||||
| 									action  | 									action  | ||||||
| 									: cmd.name  | 									: (cmd.key || cmd.name) | ||||||
| 
 | 
 | ||||||
| 								res[name] = { | 								res[name] = cmd instanceof argv.Parser ? | ||||||
| 									doc: (that.getActionAttr(action, 'doc') || '') | 									cmd | ||||||
| 										.split(/[\\\/]/g).pop(), | 										// XXX need to call the action...
 | ||||||
| 									// XXX revise argument passing...
 | 										.then(function(){ | ||||||
| 									// 		...this must be as flexible as possible...
 | 											// XXX 
 | ||||||
| 									handler: function(rest, key, value){ | 										}) | ||||||
| 										return that[action](value) }, | 									: { | ||||||
| 									...cmd, | 										doc: (that.getActionAttr(action, 'doc') || '') | ||||||
| 								} | 											.split(/[\\\/]/g).pop(), | ||||||
|  | 										// XXX revise argument passing...
 | ||||||
|  | 										// 		...this must be as flexible as possible...
 | ||||||
|  | 										handler: function(rest, key, value){ | ||||||
|  | 											return that[action](value) }, | ||||||
|  | 										...cmd, | ||||||
|  | 									} | ||||||
| 
 | 
 | ||||||
| 								return res }, {}), | 								return res }, {}), | ||||||
| 					}) | 					}) | ||||||
| @ -344,8 +431,14 @@ module.CLI = core.ImageGridFeatures.Feature({ | |||||||
| 
 | 
 | ||||||
| 				// XXX is this the right way to trigger state change 
 | 				// XXX is this the right way to trigger state change 
 | ||||||
| 				// 		from within a state action...
 | 				// 		from within a state action...
 | ||||||
| 				!this._keep_running | 				!this.__keep_running | ||||||
| 					&& this.afterAction(function(){ process.exit() }) | 					&& this.afterAction(function(){  | ||||||
|  | 						// NOTE: the timeout is here to let the progress bar
 | ||||||
|  | 						// 		catch up drawing...
 | ||||||
|  | 						setTimeout(process.exit.bind(process), 100) }) | ||||||
|  | 					// XXX odd, this seems to kill everything BEFORE we 
 | ||||||
|  | 					// 		are done while .afterAction(..) works fine...
 | ||||||
|  | 					//&& setTimeout(process.exit.bind(process), 200)
 | ||||||
| 			}], | 			}], | ||||||
| 	], | 	], | ||||||
| }) | }) | ||||||
|  | |||||||
| @ -85,6 +85,7 @@ $(function(){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// report stuff...
 | 	// report stuff...
 | ||||||
|  | 	/* | ||||||
| 	console.log('Loaded features:', | 	console.log('Loaded features:', | ||||||
| 		ig.features.features) | 		ig.features.features) | ||||||
| 	console.log('Disabled features:',  | 	console.log('Disabled features:',  | ||||||
| @ -95,6 +96,7 @@ $(function(){ | |||||||
| 	ig.features.excluded.length > 0  | 	ig.features.excluded.length > 0  | ||||||
| 		&& console.warn('Excluded features:', | 		&& console.warn('Excluded features:', | ||||||
| 			ig.features.excluded) | 			ig.features.excluded) | ||||||
|  | 	//*/
 | ||||||
| 
 | 
 | ||||||
| 	// NOTE: fatal errors will get reported by setup...
 | 	// NOTE: fatal errors will get reported by setup...
 | ||||||
| 	if(ig.features.error){ | 	if(ig.features.error){ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user