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