Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7a72de8 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by Android (Google) Code Review
Browse files

Merge "Define arguments for commands in dicttoolkit."

parents 37f5b0d4 79273b04
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -25,10 +25,16 @@ LATIN_IME_DICT_TOOLKIT_SRC_FILES := \
    $(addprefix offdevice_intermediate_dict/, \
        offdevice_intermediate_dict.cpp) \
    $(addprefix utils/, \
        arguments_parser.cpp \
        command_utils.cpp \
        utf8_utils.cpp)

LATIN_IME_DICT_TOOLKIT_TEST_FILES := \
    $(addprefix command_executors/, \
        diff_executor_test.cpp \
        header_executor_test.cpp \
        info_executor_test.cpp \
        makedict_executor_test.cpp) \
    dict_toolkit_defines_test.cpp \
    $(addprefix offdevice_intermediate_dict/, \
        offdevice_intermediate_dict_test.cpp) \
+13 −2
Original line number Diff line number Diff line
@@ -30,8 +30,19 @@ const char *const DiffExecutor::COMMAND_NAME = "diff";

/* static */ void DiffExecutor::printUsage() {
    printf("*** %s\n", COMMAND_NAME);
    printf("Usage: %s\n", COMMAND_NAME);
    printf("Shows differences between two dictionaries.\n\n");
    getArgumentsParser().printUsage(COMMAND_NAME, "Shows differences between two dictionaries.");
}

/* static */ const ArgumentsParser DiffExecutor::getArgumentsParser() {
    std::unordered_map<std::string, OptionSpec> optionSpecs;
    optionSpecs["p"] = OptionSpec::switchOption("(plumbing) produce output suitable for a script");

    const std::vector<ArgumentSpec> argumentSpecs = {
        ArgumentSpec::singleArgument("dict1", "dictionary file"),
        ArgumentSpec::singleArgument("dict2", "dictionary file")
    };

    return ArgumentsParser(std::move(optionSpecs), std::move(argumentSpecs));
}

} // namespace dicttoolkit
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define LATINIME_DICT_TOOLKIT_DIFF_EXECUTOR_H

#include "dict_toolkit_defines.h"
#include "utils/arguments_parser.h"

namespace latinime {
namespace dicttoolkit {
@@ -28,6 +29,7 @@ class DiffExecutor final {

    static int run(const int argc, char **argv);
    static void printUsage();
    static const ArgumentsParser getArgumentsParser();

 private:
    DISALLOW_IMPLICIT_CONSTRUCTORS(DiffExecutor);
+12 −2
Original line number Diff line number Diff line
@@ -30,9 +30,19 @@ const char *const HeaderExecutor::COMMAND_NAME = "header";

/* 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");
    getArgumentsParser().printUsage(COMMAND_NAME,
            "Prints the header contents of a dictionary file.");
}

/* static */ const ArgumentsParser HeaderExecutor::getArgumentsParser() {
    std::unordered_map<std::string, OptionSpec> optionSpecs;
    optionSpecs["p"] = OptionSpec::switchOption("(plumbing) produce output suitable for a script");

    const std::vector<ArgumentSpec> argumentSpecs = {
        ArgumentSpec::singleArgument("dict", "prints the header contents of a dictionary file")
    };

    return ArgumentsParser(std::move(optionSpecs), std::move(argumentSpecs));
}
} // namespace dicttoolkit
} // namespace latinime
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define LATINIME_DICT_TOOLKIT_HEADER_EXECUTOR_H

#include "dict_toolkit_defines.h"
#include "utils/arguments_parser.h"

namespace latinime {
namespace dicttoolkit {
@@ -28,6 +29,7 @@ class HeaderExecutor final {

    static int run(const int argc, char **argv);
    static void printUsage();
    static const ArgumentsParser getArgumentsParser();

 private:
    DISALLOW_IMPLICIT_CONSTRUCTORS(HeaderExecutor);
Loading