42 std::string usage =
"Extracts FSTs from a finite-state archive.\n\n Usage:";
44 usage +=
" [in1.far in2.far...]\n";
46 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
49 std::vector<std::string> sources;
50 for (
int i = 1; i < argc; ++i) sources.push_back(argv[i]);
51 if (sources.empty()) sources.push_back(
"");
52 std::unique_ptr<FarReaderClass> reader(FarReaderClass::Open(sources));
53 if (!reader)
return 1;
55 s::Extract(*reader, FST_FLAGS_generate_filenames,
56 FST_FLAGS_keys, FST_FLAGS_key_separator,
57 FST_FLAGS_range_delimiter,
58 FST_FLAGS_filename_prefix,
59 FST_FLAGS_filename_suffix);
61 if (reader->Error()) {
62 FSTERROR() <<
"Error reading FAR(s)";
void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp)
DECLARE_string(filename_prefix)
#define SET_FLAGS(usage, argc, argv, rmflags)
DECLARE_int32(generate_filenames)
int farextract_main(int argc, char **argv)
void Extract(FarReaderClass &reader, int32_t generate_sources, const std::string &keys, const std::string &key_separator, const std::string &range_delimiter, const std::string &source_prefix, const std::string &source_suffix)