| 117 | }); |
| 118 | |
| 119 | function transformCLI(infoTypes, customInfoTypes) { |
| 120 | infoTypes = infoTypes |
| 121 | ? infoTypes.split(',').map(type => { |
| 122 | return {name: type}; |
| 123 | }) |
| 124 | : undefined; |
| 125 | |
| 126 | if (customInfoTypes) { |
| 127 | customInfoTypes = customInfoTypes.includes(',') |
| 128 | ? customInfoTypes.split(',').map((dict, idx) => { |
| 129 | return { |
| 130 | infoType: {name: 'CUSTOM_DICT_'.concat(idx.toString())}, |
| 131 | dictionary: {wordList: {words: dict.split(',')}}, |
| 132 | }; |
| 133 | }) |
| 134 | : customInfoTypes.split(',').map((rgx, idx) => { |
| 135 | return { |
| 136 | infoType: {name: 'CUSTOM_REGEX_'.concat(idx.toString())}, |
| 137 | regex: {pattern: rgx}, |
| 138 | }; |
| 139 | }); |
| 140 | } |
| 141 | |
| 142 | return [infoTypes, customInfoTypes]; |
| 143 | } |