github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/gen/parser/create_array_doc.yaml (about) 1 - DocumentID: create-array 2 Title: >- 3 `%[]` Create Array 4 CategoryID: parser 5 Summary: >- 6 Quickly generate arrays 7 Description: |- 8 `%[]` is a way of defining arrays in expressions and statements. Whenever a 9 `%[]` array is outputted as a string, it will be converted to minified JSON. 10 11 Array elements inside `%[]` can be whitespace and/or comma delimited. This 12 allows for compatibility with both Bash muscle memory, and people more 13 familiar with JSON. 14 15 Additionally you can also embed `a` style parameters inside `%[]` arrays too. 16 17 Like with YAML, strings in `%[]` do not need to be quoted unless you need to 18 force numeric or boolean looking values to be stored as strings. 19 Examples: |- 20 ### Arrays passed as a JSON string: 21 22 ``` 23 » echo %[1..3] 24 [1,2,3] 25 26 » %[1..3] -> cat 27 [1,2,3] 28 ``` 29 30 ### Different supported syntax for creating a numeric array: 31 32 #### As a range 33 34 ``` 35 » %[1..3] 36 [ 37 1, 38 2, 39 3 40 ] 41 ``` 42 43 #### JSON formatted 44 45 ``` 46 » %[1,2,3] 47 [ 48 1, 49 2, 50 3 51 ] 52 ``` 53 54 #### Whitespace separated 55 56 ``` 57 » %[1 2 3] 58 [ 59 1, 60 2, 61 3 62 ] 63 ``` 64 65 #### Values and ranges 66 67 ``` 68 » %[1,2..3] 69 [ 70 1, 71 2, 72 3 73 ] 74 ``` 75 76 ### Strings: 77 78 #### barewords and whitespace separated 79 80 This will allow you to copy/paste lists from traditional shells like Bash 81 82 ``` 83 » %[foo bar] 84 [ 85 "foo", 86 "bar" 87 ] 88 ``` 89 90 #### JSON formatted 91 92 ``` 93 » %["foo", "bar"] 94 [ 95 "foo", 96 "bar" 97 ] 98 ``` 99 100 ### Special ranges 101 102 ``` 103 » %[June..August] 104 [ 105 "June", 106 "July", 107 "August" 108 ] 109 ``` 110 111 A full list of special ranges are available at [docs/mkarray/special](../mkarray/special.md) 112 113 ### Multiple expansion blocks: 114 115 ``` 116 » %[[A,B]:[1..4]] 117 [ 118 "A:1", 119 "A:2", 120 "A:3", 121 "A:4", 122 "B:1", 123 "B:2", 124 "B:3", 125 "B:4" 126 ] 127 ``` 128 129 ### Nested arrays: 130 131 ``` 132 » %[foo [bar]] 133 [ 134 "foo", 135 [ 136 "bar" 137 ] 138 ] 139 ``` 140 141 The `%` prefix for the nested array is optional. 142 143 ### JSON objects within arrays 144 145 ``` 146 » %[foo {bar: baz}] 147 [ 148 "foo", 149 { 150 "bar": "baz" 151 } 152 ] 153 ``` 154 155 The `%` prefix for the nested object is optional. 156 Detail: |- 157 Murex supports a number of different formats that can be used to generate 158 arrays. For more details on these please refer to the documents for each format 159 160 {{ include "gen/includes/autogenerated.mkarray.inc.md" }} 161 Related: 162 - create-object 163 - single-quote 164 - double-quote 165 - brace-quote 166 - expr 167 - mkarray/special 168 - a 169 - ja 170 - ta