#include "src/DictConverter.hpp"
#include "src/CmdLineOutput.hpp"
#include "src/Exception.hpp"
using namespace opencc;
int main(int argc, const char* argv[]) {
try {
TCLAP::CmdLine cmd("Open Chinese Convert (OpenCC) Dictionary Tool", ' ',
VERSION);
CmdLineOutput cmdLineOutput;
cmd.setOutput(&cmdLineOutput);
std::vector<std::string> dictFormats{"text", "ocd2", "ocd"};
TCLAP::ValuesConstraint<std::string> allowedVals(dictFormats);
TCLAP::ValueArg<std::string> toArg("t", "to", "Output format",
true , "" ,
&allowedVals , cmd);
TCLAP::ValueArg<std::string> fromArg("f", "from", "Input format",
true , "" ,
&allowedVals , cmd);
TCLAP::ValueArg<std::string> outputArg(
"o", "output", "Path to output dictionary", true ,
"" , "file" , cmd);
TCLAP::ValueArg<std::string> inputArg(
"i", "input", "Path to input dictionary", true ,
"" , "file" , cmd);
cmd.parse(argc, argv);
ConvertDictionary(inputArg.getValue(), outputArg.getValue(),
fromArg.getValue(), toArg.getValue());
} catch (TCLAP::ArgException& e) {
std::cerr << "error: " << e.error() << " for arg " << e.argId()
<< std::endl;
} catch (Exception& e) {
std::cerr << e.what() << std::endl;
}
return 0;
}