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
19#include "dict_toolkit_defines.h"
20#include "utils/command_utils.h"
21
22void usage(int argc, char **argv) {
23    fprintf(stderr, "Usage: %s <command> [arguments]\n", argc > 0 ? argv[0] : "dicttoolkit");
24}
25
26int main(int argc, char **argv) {
27    if (argc < MIN_ARG_COUNT) {
28        usage(argc, argv);
29        return 1;
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]);
35        return 1;
36    }
37    const auto executor = CommandUtils::getCommandExecutor(commandType);
38    return executor(argc - 1, argv + 1);
39}
40