()
| 211 | } |
| 212 | |
| 213 | function main() { |
| 214 | let options; |
| 215 | try { |
| 216 | options = parseArgs(process.argv.slice(2)); |
| 217 | } catch (error) { |
| 218 | fail(error.message); |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | if (options.help) { |
| 223 | printHelp(); |
| 224 | return; |
| 225 | } |
| 226 | |
| 227 | if (options.version) { |
| 228 | console.log(OpenCC.version); |
| 229 | return; |
| 230 | } |
| 231 | |
| 232 | try { |
| 233 | const converter = new OpenCC(resolveConfigPath(options.config), { |
| 234 | includeTofuRiskDictionaries: options.includeTofuRiskDictionaries, |
| 235 | resourceZip: options.resourceZip, |
| 236 | }); |
| 237 | convertStream(converter, options, (error) => { |
| 238 | if (error) { |
| 239 | const message = error && error.message ? error.message : String(error); |
| 240 | fail(path.basename(process.argv[1]) + ': ' + message); |
| 241 | } |
| 242 | }); |
| 243 | } catch (error) { |
| 244 | const message = error && error.message ? error.message : String(error); |
| 245 | fail(path.basename(process.argv[1]) + ': ' + message); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | main(); |
no test coverage detected