Keisuke Kuroyanagi | e101a53 | 2014-10-31 20:27:06 +0900 | [diff] [blame] | 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 <cstdio> |
| 18 | |
Keisuke Kuroyanagi | 4bfa3b2 | 2014-11-07 06:49:34 +0900 | [diff] [blame] | 19 | #include "dict_toolkit_defines.h" |
| 20 | #include "utils/command_utils.h" |
| 21 | |
| 22 | void usage(int argc, char **argv) { |
| 23 | fprintf(stderr, "Usage: %s <command> [arguments]\n", argc > 0 ? argv[0] : "dicttoolkit"); |
| 24 | } |
| 25 | |
Keisuke Kuroyanagi | e101a53 | 2014-10-31 20:27:06 +0900 | [diff] [blame] | 26 | int main(int argc, char **argv) { |
Keisuke Kuroyanagi | 4bfa3b2 | 2014-11-07 06:49:34 +0900 | [diff] [blame] | 27 | if (argc < MIN_ARG_COUNT) { |
| 28 | usage(argc, argv); |
Keisuke Kuroyanagi | bd48963 | 2014-11-08 05:23:05 +0900 | [diff] [blame^] | 29 | return 1; |
Keisuke Kuroyanagi | 4bfa3b2 | 2014-11-07 06:49:34 +0900 | [diff] [blame] | 30 | } |
| 31 | using namespace latinime::dicttoolkit; |
| 32 | const CommandType commandType = CommandUtils::getCommandType(argv[1]); |
| 33 | if (commandType == CommandType::Unknown) { |
| 34 | CommandUtils::printCommandUnknownMessage(argv[0], argv[1]); |
Keisuke Kuroyanagi | bd48963 | 2014-11-08 05:23:05 +0900 | [diff] [blame^] | 35 | return 1; |
Keisuke Kuroyanagi | 4bfa3b2 | 2014-11-07 06:49:34 +0900 | [diff] [blame] | 36 | } |
Keisuke Kuroyanagi | bd48963 | 2014-11-08 05:23:05 +0900 | [diff] [blame^] | 37 | const auto executor = CommandUtils::getCommandExecutor(commandType); |
| 38 | return executor(argc - 1, argv + 1); |
Keisuke Kuroyanagi | e101a53 | 2014-10-31 20:27:06 +0900 | [diff] [blame] | 39 | } |