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