| 
									
										
										
										
											2020-06-14 03:10:19 +03:00
										 |  |  | #!/usr/bin/env node
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | **********************************************************************/ | 
					
						
							|  |  |  | ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) | 
					
						
							|  |  |  | (function(require){ var module={} // make module AMD/node compatible...
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var colors = require('colors') | 
					
						
							|  |  |  | var object = require('ig-object') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var argv = require('./argv') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //---------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-16 15:48:43 +03:00
										 |  |  | var p =  | 
					
						
							|  |  |  | module.p = | 
					
						
							|  |  |  | argv.Parser({ | 
					
						
							| 
									
										
										
										
											2020-06-25 18:31:06 +03:00
										 |  |  | 		// disable exit on error...
 | 
					
						
							|  |  |  | 		handleErrorExit: false, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-16 18:31:58 +03:00
										 |  |  | 		'@help': '-help', | 
					
						
							| 
									
										
										
										
											2020-06-16 15:48:43 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-16 18:31:58 +03:00
										 |  |  | 		'-verbose': function(){ | 
					
						
							|  |  |  | 			console.log('>>> VERBOSE:', ...arguments) | 
					
						
							|  |  |  | 			return 'verbose' | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2020-06-16 15:48:43 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-16 18:31:58 +03:00
										 |  |  | 		'-c': '@command', | 
					
						
							|  |  |  | 		'@cmd': '@command', | 
					
						
							|  |  |  | 		'@command': { | 
					
						
							|  |  |  | 			priority: -50, | 
					
						
							|  |  |  | 			handler: function(){ | 
					
						
							|  |  |  | 				console.log('>>> COMMAND:', ...arguments) | 
					
						
							|  |  |  | 				return 'command' | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2020-06-16 15:48:43 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-16 18:31:58 +03:00
										 |  |  | 		'@test': argv.Parser({ | 
					
						
							| 
									
										
										
										
											2020-06-29 15:25:59 +03:00
										 |  |  | 			// XXX ENV
 | 
					
						
							|  |  |  | 			//env: 'TEST',
 | 
					
						
							| 
									
										
										
										
											2020-06-16 18:31:58 +03:00
										 |  |  | 		}), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'@nested': argv.Parser({ | 
					
						
							|  |  |  | 			doc: 'nested parser.', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			'@nested': argv.Parser({ | 
					
						
							|  |  |  | 				doc: 'nested nested parser.', | 
					
						
							| 
									
										
										
										
											2020-06-29 14:05:55 +03:00
										 |  |  | 			}).then(function(){ | 
					
						
							|  |  |  | 				console.log('NESTED NESTED DONE', ...arguments)}), | 
					
						
							|  |  |  | 		}).then(function(){ | 
					
						
							|  |  |  | 			console.log('NESTED DONE', ...arguments) }), | 
					
						
							| 
									
										
										
										
											2020-06-28 02:13:43 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// these aliases will not get shown...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// dead-end alias...
 | 
					
						
							|  |  |  | 		'-d': '-dead-end', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// alias loops...
 | 
					
						
							|  |  |  | 		'-z': '-z', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'-x': '-y', | 
					
						
							|  |  |  | 		'-y': '-x', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'-a': '-b', | 
					
						
							|  |  |  | 		'-b': '-c', | 
					
						
							|  |  |  | 		'-c': '-a', | 
					
						
							| 
									
										
										
										
											2020-06-16 18:31:58 +03:00
										 |  |  | 	}) | 
					
						
							|  |  |  | 	.then(function(){ | 
					
						
							| 
									
										
										
										
											2020-06-29 02:51:06 +03:00
										 |  |  | 		console.log('DONE', ...arguments) }) | 
					
						
							| 
									
										
										
										
											2020-06-16 18:31:58 +03:00
										 |  |  | 	.stop(function(){ | 
					
						
							|  |  |  | 		console.log('STOP') }) | 
					
						
							|  |  |  | 	.error(function(){ | 
					
						
							|  |  |  | 		console.log('ERROR') }) | 
					
						
							| 
									
										
										
										
											2020-06-15 17:17:04 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-16 15:48:43 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							| 
									
										
										
										
											2020-06-15 17:17:04 +03:00
										 |  |  | console.log('  ->', p(['test', '--verbose', 'a', 'b', 'c'])) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | console.log('  ->', p(['test', '-c', 'a', 'b', 'c'])) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | console.log('  ->', p(['test', 'command', 'a', 'b', 'c'])) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | console.log('---') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-16 15:48:43 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | p(['test', 'nested', '-h']) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-15 17:17:04 +03:00
										 |  |  | p(['test', '-h']) | 
					
						
							| 
									
										
										
										
											2020-06-16 15:48:43 +03:00
										 |  |  | //*/
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if(typeof(__filename) != 'undefined' | 
					
						
							|  |  |  | 		&& __filename == (require.main || {}).filename){ | 
					
						
							| 
									
										
										
										
											2020-06-14 03:10:19 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-16 15:48:43 +03:00
										 |  |  | 	p(process.argv) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-06-14 03:10:19 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							|  |  |  | * vim:set ts=4 sw=4 :                               */ return module }) |