• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "command_executors/makedict_executor.h"
18 
19 #include <cstdio>
20 
21 namespace latinime {
22 namespace dicttoolkit {
23 
24 const char *const MakedictExecutor::COMMAND_NAME = "makedict";
25 
run(const int argc,char ** argv)26 /* static */ int MakedictExecutor::run(const int argc, char **argv) {
27     const ArgumentsAndOptions argumentsAndOptions =
28             getArgumentsParser().parseArguments(argc, argv, true /* printErrorMessages */);
29     if (!argumentsAndOptions.isValid()) {
30         printUsage();
31         return 1;
32     }
33     fprintf(stderr, "Command '%s' has not been implemented yet.\n", COMMAND_NAME);
34     return 0;
35 }
36 
printUsage()37 /* static */ void MakedictExecutor::printUsage() {
38     printf("*** %s\n", COMMAND_NAME);
39     getArgumentsParser().printUsage(COMMAND_NAME,
40             "Converts a source dictionary file to one or several outputs.\n"
41             "Source can be a binary dictionary file or a combined format file.\n"
42             "Binary version 2 (Jelly Bean), 4, and combined format outputs are supported.");
43 }
44 
getArgumentsParser()45 /* static */const ArgumentsParser MakedictExecutor::getArgumentsParser() {
46     std::unordered_map<std::string, OptionSpec> optionSpecs;
47     optionSpecs["o"] = OptionSpec::keyValueOption("format", "2",
48             "output format version: 2/4/combined");
49     optionSpecs["t"] = OptionSpec::keyValueOption("mode", "off",
50             "code point table switch: on/off/auto");
51 
52     const std::vector<ArgumentSpec> argumentSpecs = {
53         ArgumentSpec::singleArgument("src_dict", "source dictionary file"),
54         ArgumentSpec::singleArgument("dest_dict", "output dictionary file")
55     };
56 
57     return ArgumentsParser(std::move(optionSpecs), std::move(argumentSpecs));
58 }
59 
60 } // namespace dicttoolkit
61 } // namespace latinime
62