mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Updated docs
This commit is contained in:
		
							parent
							
								
									e92180e89d
								
							
						
					
					
						commit
						9509831cff
					
				| @ -26,7 +26,7 @@ a: frog | |||||||
| ``` | ``` | ||||||
| then | then | ||||||
| ```bash | ```bash | ||||||
| yq eval 'select(. | documentIndex == 1)' sample.yml | yq eval 'select(documentIndex == 1)' sample.yml | ||||||
| ``` | ``` | ||||||
| will output | will output | ||||||
| ```yaml | ```yaml | ||||||
| @ -42,7 +42,7 @@ a: frog | |||||||
| ``` | ``` | ||||||
| then | then | ||||||
| ```bash | ```bash | ||||||
| yq eval '.a | ({"match": ., "doc": (. | documentIndex)})' sample.yml | yq eval '.a | ({"match": ., "doc": documentIndex})' sample.yml | ||||||
| ``` | ``` | ||||||
| will output | will output | ||||||
| ```yaml | ```yaml | ||||||
|  | |||||||
| @ -146,7 +146,7 @@ will output | |||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Pretty print | ## Pretty print | ||||||
| Set empty (default) quote style, note the usage of `...` to match keys too. | Set empty (default) quote style, note the usage of `...` to match keys too. Note that there is a `--prettyPrint/-P` short flag for this. | ||||||
| 
 | 
 | ||||||
| Given a sample.yml file of: | Given a sample.yml file of: | ||||||
| ```yaml | ```yaml | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ var documentIndexScenarios = []expressionScenario{ | |||||||
| 	{ | 	{ | ||||||
| 		description: "Filter by document index", | 		description: "Filter by document index", | ||||||
| 		document:    "a: cat\n---\na: frog\n", | 		document:    "a: cat\n---\na: frog\n", | ||||||
| 		expression:  `select(. | documentIndex == 1)`, | 		expression:  `select(documentIndex == 1)`, | ||||||
| 		expected: []string{ | 		expected: []string{ | ||||||
| 			"D1, P[], (doc)::a: frog\n", | 			"D1, P[], (doc)::a: frog\n", | ||||||
| 		}, | 		}, | ||||||
| @ -25,7 +25,7 @@ var documentIndexScenarios = []expressionScenario{ | |||||||
| 	{ | 	{ | ||||||
| 		description: "Print Document Index with matches", | 		description: "Print Document Index with matches", | ||||||
| 		document:    "a: cat\n---\na: frog\n", | 		document:    "a: cat\n---\na: frog\n", | ||||||
| 		expression:  `.a | ({"match": ., "doc": (. | documentIndex)})`, | 		expression:  `.a | ({"match": ., "doc": documentIndex})`, | ||||||
| 		expected: []string{ | 		expected: []string{ | ||||||
| 			"D0, P[], (!!map)::match: cat\ndoc: 0\n", | 			"D0, P[], (!!map)::match: cat\ndoc: 0\n", | ||||||
| 			"D0, P[], (!!map)::match: frog\ndoc: 1\n", | 			"D0, P[], (!!map)::match: frog\ndoc: 1\n", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user