diff --git a/native/dicttoolkit/src/command_executors/diff_executor.cpp b/native/dicttoolkit/src/command_executors/diff_executor.cpp index 1fe90a9f63009c26df5610ff59a3333884406437..077a40090b9db8e41324b4889a23dbcf3807db49 100644 --- a/native/dicttoolkit/src/command_executors/diff_executor.cpp +++ b/native/dicttoolkit/src/command_executors/diff_executor.cpp @@ -28,5 +28,11 @@ const char *const DiffExecutor::COMMAND_NAME = "diff"; return 0; } +/* static */ void DiffExecutor::printUsage() { + printf("*** %s\n", COMMAND_NAME); + printf("Usage: %s\n", COMMAND_NAME); + printf("Shows differences between two dictionaries.\n\n"); +} + } // namespace dicttoolkit } // namespace latinime diff --git a/native/dicttoolkit/src/command_executors/diff_executor.h b/native/dicttoolkit/src/command_executors/diff_executor.h index 5b4e9e609a990bf2e64906be6ff2fd42cc4a70ee..fc8dc0d8f375de4aa87a6a516c8b18216d9dd84c 100644 --- a/native/dicttoolkit/src/command_executors/diff_executor.h +++ b/native/dicttoolkit/src/command_executors/diff_executor.h @@ -27,6 +27,7 @@ class DiffExecutor final { static const char *const COMMAND_NAME; static int run(const int argc, char **argv); + static void printUsage(); private: DISALLOW_IMPLICIT_CONSTRUCTORS(DiffExecutor); diff --git a/native/dicttoolkit/src/command_executors/header_executor.cpp b/native/dicttoolkit/src/command_executors/header_executor.cpp index ec2ca8119d1d69862f832313778f2eec1e4d18c0..068a62c3119b8b975cc336f564f9f9768bf6fc2b 100644 --- a/native/dicttoolkit/src/command_executors/header_executor.cpp +++ b/native/dicttoolkit/src/command_executors/header_executor.cpp @@ -28,5 +28,11 @@ const char *const HeaderExecutor::COMMAND_NAME = "header"; return 0; } +/* static */ void HeaderExecutor::printUsage() { + printf("*** %s\n", COMMAND_NAME); + printf("Usage: %s\n", COMMAND_NAME); + printf("Prints the header contents of a dictionary file.\n\n"); +} + } // namespace dicttoolkit } // namespace latinime diff --git a/native/dicttoolkit/src/command_executors/header_executor.h b/native/dicttoolkit/src/command_executors/header_executor.h index b482e6bb659d2de69a71d4843f44dab5f7da5158..4cdeb1a9991431e32217a0fc85255062f5c3daef 100644 --- a/native/dicttoolkit/src/command_executors/header_executor.h +++ b/native/dicttoolkit/src/command_executors/header_executor.h @@ -27,6 +27,7 @@ class HeaderExecutor final { static const char *const COMMAND_NAME; static int run(const int argc, char **argv); + static void printUsage(); private: DISALLOW_IMPLICIT_CONSTRUCTORS(HeaderExecutor); diff --git a/native/dicttoolkit/src/command_executors/help_executor.cpp b/native/dicttoolkit/src/command_executors/help_executor.cpp index dba9f79fc5ce0a753f73263a064952f3d13e4339..bd29a5b167d11d2fbe3f217efa40e2d7b2972496 100644 --- a/native/dicttoolkit/src/command_executors/help_executor.cpp +++ b/native/dicttoolkit/src/command_executors/help_executor.cpp @@ -17,6 +17,14 @@ #include "command_executors/help_executor.h" #include <cstdio> +#include <functional> +#include <vector> + +#include "command_executors/diff_executor.h" +#include "command_executors/header_executor.h" +#include "command_executors/info_executor.h" +#include "command_executors/makedict_executor.h" +#include "utils/command_utils.h" namespace latinime { namespace dicttoolkit { @@ -24,9 +32,21 @@ namespace dicttoolkit { const char *const HelpExecutor::COMMAND_NAME = "help"; /* static */ int HelpExecutor::run(const int argc, char **argv) { - fprintf(stderr, "Command '%s' has not been implemented yet.\n", COMMAND_NAME); + printf("Available commands:\n\n"); + const std::vector<std::function<void(void)>> printUsageMethods = {DiffExecutor::printUsage, + HeaderExecutor::printUsage, InfoExecutor::printUsage, MakedictExecutor::printUsage, + printUsage}; + for (const auto &printUsageMethod : printUsageMethods) { + printUsageMethod(); + } return 0; } +/* static */ void HelpExecutor::printUsage() { + printf("*** %s\n", COMMAND_NAME); + printf("Usage: %s\n", COMMAND_NAME); + printf("Show this help list.\n\n"); +} + } // namespace dicttoolkit } // namespace latinime diff --git a/native/dicttoolkit/src/command_executors/help_executor.h b/native/dicttoolkit/src/command_executors/help_executor.h index 245fda9b4b9d7fcb27f23b69a4fee8afaf858be8..280610eb9d0278864b624eaaa1df0db7b6981403 100644 --- a/native/dicttoolkit/src/command_executors/help_executor.h +++ b/native/dicttoolkit/src/command_executors/help_executor.h @@ -27,6 +27,7 @@ class HelpExecutor final { static const char *const COMMAND_NAME; static int run(const int argc, char **argv); + static void printUsage(); private: DISALLOW_IMPLICIT_CONSTRUCTORS(HelpExecutor); diff --git a/native/dicttoolkit/src/command_executors/info_executor.cpp b/native/dicttoolkit/src/command_executors/info_executor.cpp index 5c9a6366aaf42cbfccf6be20a9f6c2004ffafc5e..c4d84cab36ee7d9ab9f9b8798cf0bdd1fd8b33ae 100644 --- a/native/dicttoolkit/src/command_executors/info_executor.cpp +++ b/native/dicttoolkit/src/command_executors/info_executor.cpp @@ -28,5 +28,11 @@ const char *const InfoExecutor::COMMAND_NAME = "info"; return 0; } +/* static */ void InfoExecutor::printUsage() { + printf("*** %s\n", COMMAND_NAME); + printf("Usage: %s\n", COMMAND_NAME); + printf("Prints various information about a dictionary file.\n\n"); +} + } // namespace dicttoolkit } // namespace latinime diff --git a/native/dicttoolkit/src/command_executors/info_executor.h b/native/dicttoolkit/src/command_executors/info_executor.h index b42bc0e8eca4f841b0eb92ee548949f48faa74ec..4ffa74fb037ba824ea587a824a03f2ba0d24ac8b 100644 --- a/native/dicttoolkit/src/command_executors/info_executor.h +++ b/native/dicttoolkit/src/command_executors/info_executor.h @@ -27,6 +27,7 @@ class InfoExecutor final { static const char *const COMMAND_NAME; static int run(const int argc, char **argv); + static void printUsage(); private: DISALLOW_IMPLICIT_CONSTRUCTORS(InfoExecutor); diff --git a/native/dicttoolkit/src/command_executors/makedict_executor.cpp b/native/dicttoolkit/src/command_executors/makedict_executor.cpp index 5466a5917e1c719cadfa4ac693bc99d07e2f65f3..ea62e3c37ca8167591b6a7364b158eb313b90cdb 100644 --- a/native/dicttoolkit/src/command_executors/makedict_executor.cpp +++ b/native/dicttoolkit/src/command_executors/makedict_executor.cpp @@ -28,5 +28,13 @@ const char *const MakedictExecutor::COMMAND_NAME = "makedict"; return 0; } +/* static */ void MakedictExecutor::printUsage() { + printf("*** %s\n", COMMAND_NAME); + printf("Usage: %s\n", COMMAND_NAME); + printf("Converts a source dictionary file to one or several outputs.\n" + "Source can be a binary dictionary file or a combined format file.\n" + "Binary version 2 (Jelly Bean), 4, and combined format outputs are supported.\n\n"); +} + } // namespace dicttoolkit } // namespace latinime diff --git a/native/dicttoolkit/src/command_executors/makedict_executor.h b/native/dicttoolkit/src/command_executors/makedict_executor.h index 466d1f7e289f31ee6bc89e380404fa848a1f89a3..ae1309f60c12118a350d626158874b6afe7cadc0 100644 --- a/native/dicttoolkit/src/command_executors/makedict_executor.h +++ b/native/dicttoolkit/src/command_executors/makedict_executor.h @@ -27,6 +27,7 @@ class MakedictExecutor final { static const char *const COMMAND_NAME; static int run(const int argc, char **argv); + static void printUsage(); private: DISALLOW_IMPLICIT_CONSTRUCTORS(MakedictExecutor);