40 "Creates a finite-state archive from input FSTs.\n\n Usage:";
42 usage +=
" [in1.fst [[in2.fst ...] out.far]]\n";
45 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
48 std::vector<std::string> sources;
49 if (FST_FLAGS_file_list_input) {
50 for (
int i = 1; i < argc - 1; ++i) {
51 std::ifstream istrm(argv[i]);
53 while (std::getline(istrm, str)) sources.push_back(str);
56 for (
int i = 1; i < argc - 1; ++i)
57 sources.push_back(strcmp(argv[i],
"-") != 0 ? argv[i] :
"");
58 if (sources.empty()) {
61 sources.push_back(argc == 2 && strcmp(argv[1],
"-") != 0 ? argv[1] :
"");
66 const std::string out_far =
67 argc > 2 && strcmp(argv[argc - 1],
"-") != 0 ? argv[argc - 1] :
"";
71 LOG(ERROR) <<
"Unknown or unsupported FAR type: " 72 << FST_FLAGS_far_type;
77 if (!sources.empty()) {
79 if (arc_type.empty())
return 1;
82 std::unique_ptr<FarWriterClass> writer(
84 if (!writer)
return 1;
86 s::Create(sources, *writer, FST_FLAGS_generate_keys,
87 FST_FLAGS_key_prefix, FST_FLAGS_key_suffix);
89 if (writer->Error()) {
90 FSTERROR() <<
"Error writing FAR: " << out_far;
DECLARE_int32(generate_keys)
void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp)
int farcreate_main(int argc, char **argv)
static const std::string & Type()
std::string LoadArcTypeFromFst(const std::string &fst_source)
#define SET_FLAGS(usage, argc, argv, rmflags)
DECLARE_string(key_prefix)
bool GetFarType(std::string_view str, FarType *far_type)
DECLARE_bool(file_list_input)
void Create(const std::vector< std::string > &sources, FarWriterClass &writer, const int32_t generate_keys, const std::string &key_prefix, const std::string &key_suffix)