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

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

Merge "Implement help command for dicttoolkit."

parents b23f0348 395f6e70
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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);
+6 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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);
+21 −1
Original line number Diff line number Diff line
@@ -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
Loading