mirror of
				https://github.com/flynx/argv.js.git
				synced 2025-10-31 03:30:08 +00:00 
			
		
		
		
	aesthetic tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									d3762f4f9c
								
							
						
					
					
						commit
						f116282044
					
				
							
								
								
									
										35
									
								
								argv.js
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								argv.js
									
									
									
									
									
								
							| @ -424,17 +424,19 @@ object.Constructor('Parser', { | |||||||
| 	//                      /
 | 	//                      /
 | ||||||
| 	//      |<------+-------+------>|
 | 	//      |<------+-------+------>|
 | ||||||
| 	//   
 | 	//   
 | ||||||
| 	//      -o, --option=VALUE      - option doc
 | 	//      -o,  --option=VALUE     - option doc
 | ||||||
| 	//        __        _           __
 | 	//        __        _           __
 | ||||||
| 	//          \        \            \
 | 	//       _  \        \            \
 | ||||||
| 	//           \        \            +---- .helpColumnPrefix ('- ')
 | 	//        \  \        \            +---- .helpColumnPrefix ('- ')
 | ||||||
| 	//            \        \
 | 	//         \  \        \
 | ||||||
| 	//             \        +--------------- .helpValueSeparator ('=')
 | 	//          \  \        +--------------- .helpValueSeparator ('=')
 | ||||||
| 	//              \
 | 	//           \  \
 | ||||||
| 	//               +---------------------- .helpArgumentSeparator (', ')
 | 	//            \  +---------------------- .helpArgumentSeparator (', ')
 | ||||||
|  | 	//             \
 | ||||||
|  | 	//              +----------------------- .helpShortOptionSize (2 chars)
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// doc config...
 |  | ||||||
| 	helpColumnOffset: 3, | 	helpColumnOffset: 3, | ||||||
|  | 	helpShortOptionSize: 2, | ||||||
| 	helpColumnPrefix: '- ', | 	helpColumnPrefix: '- ', | ||||||
| 	helpArgumentSeparator: ', ', | 	helpArgumentSeparator: ', ', | ||||||
| 	helpValueSeparator: '=', | 	helpValueSeparator: '=', | ||||||
| @ -471,7 +473,8 @@ object.Constructor('Parser', { | |||||||
| 		priority: 99, | 		priority: 99, | ||||||
| 		handler: function(argv, key, value){ | 		handler: function(argv, key, value){ | ||||||
| 			var that = this | 			var that = this | ||||||
| 			var sep = this.helpArgumentSeparator | 			var sep = this.helpArgumentSeparator || ', ' | ||||||
|  | 			var short = this.helpShortOptionSize || 1 | ||||||
| 			var expandVars = this.expandTextVars.bind(this) | 			var expandVars = this.expandTextVars.bind(this) | ||||||
| 			var formDoc = function(doc, handler){ | 			var formDoc = function(doc, handler){ | ||||||
| 				var info = [ | 				var info = [ | ||||||
| @ -529,14 +532,20 @@ object.Constructor('Parser', { | |||||||
| 										.sort(function(a, b){  | 										.sort(function(a, b){  | ||||||
| 											return a.length - b.length}) | 											return a.length - b.length}) | ||||||
| 										// form: "-x, --xx"
 | 										// form: "-x, --xx"
 | ||||||
| 										.map(function(o, i){ | 										.map(function(o, i, l){ | ||||||
| 											return o.length <= 2 ?  | 											return o.length <= 1 + short ?  | ||||||
| 													o  | 													o  | ||||||
| 												// no short options -> offset first long option...
 | 												// no short options -> offset first long option...
 | ||||||
| 												: i == 0 ? | 												: i == 0 ? | ||||||
| 													' '.repeat(sep.length + 2) +'-'+ o | 													' '.repeat(1 + short + sep.length) +'-'+ o | ||||||
|  | 												// short option shorter than 1 + short 
 | ||||||
|  | 												// 		-> offset first long option by difference...
 | ||||||
|  | 												: i == 1 ? | ||||||
|  | 													' '.repeat(1 + short - l[0].length || 0) +'-'+ o | ||||||
| 												// add extra '-' to long options...
 | 												// add extra '-' to long options...
 | ||||||
| 												: '-'+ o }) | 												: o.length > short ? | ||||||
|  | 													'-'+ o  | ||||||
|  | 												: o }) | ||||||
| 										.join(sep), | 										.join(sep), | ||||||
| 										...(arg ?  | 										...(arg ?  | ||||||
| 											[arg]  | 											[arg]  | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "ig-argv", |   "name": "ig-argv", | ||||||
|   "version": "2.4.0", |   "version": "2.4.1", | ||||||
|   "description": "simple argv parser", |   "description": "simple argv parser", | ||||||
|   "main": "argv.js", |   "main": "argv.js", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user