| 174 | }); |
| 175 | |
| 176 | function transformCLI(infoTypes, customInfoTypes) { |
| 177 | infoTypes = infoTypes |
| 178 | ? infoTypes.split(',').map(type => { |
| 179 | return {name: type}; |
| 180 | }) |
| 181 | : undefined; |
| 182 | |
| 183 | if (customInfoTypes) { |
| 184 | customInfoTypes = customInfoTypes.includes(',') |
| 185 | ? customInfoTypes.split(',').map((dict, idx) => { |
| 186 | return { |
| 187 | infoType: {name: 'CUSTOM_DICT_'.concat(idx.toString())}, |
| 188 | dictionary: {wordList: {words: dict.split(',')}}, |
| 189 | }; |
| 190 | }) |
| 191 | : customInfoTypes.split(',').map((rgx, idx) => { |
| 192 | return { |
| 193 | infoType: {name: 'CUSTOM_REGEX_'.concat(idx.toString())}, |
| 194 | regex: {pattern: rgx}, |
| 195 | }; |
| 196 | }); |
| 197 | } |
| 198 | |
| 199 | return [infoTypes, customInfoTypes]; |
| 200 | } |
| 201 | |
| 202 | module.exports = main; |