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/help_executor.h"
18 
19 #include <cstdio>
20 #include <functional>
21 #include <vector>
22 
23 #include "command_executors/diff_executor.h"
24 #include "command_executors/header_executor.h"
25 #include "command_executors/info_executor.h"
26 #include "command_executors/makedict_executor.h"
27 #include "utils/command_utils.h"
28 
29 namespace latinime {
30 namespace dicttoolkit {
31 
32 const char *const HelpExecutor::COMMAND_NAME = "help";
33 
run(const int argc,char ** argv)34 /* static */ int HelpExecutor::run(const int argc, char **argv) {
35     printf("Available commands:\n\n");
36     const std::vector<std::function<void(void)>> printUsageMethods = {DiffExecutor::printUsage,
37             HeaderExecutor::printUsage, InfoExecutor::printUsage, MakedictExecutor::printUsage,
38             printUsage};
39     for (const auto &printUsageMethod : printUsageMethods) {
40         printUsageMethod();
41     }
42     return 0;
43 }
44 
printUsage()45 /* static */ void HelpExecutor::printUsage() {
46     printf("*** %s\n", COMMAND_NAME);
47     printf("Usage: %s\n", COMMAND_NAME);
48     printf("Show this help list.\n\n");
49 }
50 
51 } // namespace dicttoolkit
52 } // namespace latinime
53