Search in sources :

Example 1 with ToolTask

use of tools.utils.ToolTask in project AuthMeReloaded by AuthMe.

the class ToolsRunner method promptAndExecuteTask.

private void promptAndExecuteTask() {
    System.out.println("The following tasks are available:");
    for (String key : tasks.keySet()) {
        System.out.println("- " + key);
    }
    System.out.println("Please enter the task to run:");
    Scanner scanner = new Scanner(System.in);
    String inputTask = scanner.nextLine();
    ToolTask task = tasks.get(inputTask);
    if (task != null) {
        task.execute(scanner);
    } else {
        System.out.println("Unknown task");
    }
    scanner.close();
}
Also used : Scanner(java.util.Scanner) ToolTask(tools.utils.ToolTask) AutoToolTask(tools.utils.AutoToolTask)

Example 2 with ToolTask

use of tools.utils.ToolTask in project AuthMeReloaded by AuthMe.

the class UpdateDocsTask method executeTasks.

private void executeTasks(Consumer<ToolTask> taskRunner) {
    for (ToolTask task : getDocTasks()) {
        System.out.println("\nRunning " + task.getTaskName() + "\n-------------------");
        taskRunner.accept(task);
    }
}
Also used : ToolTask(tools.utils.ToolTask) AutoToolTask(tools.utils.AutoToolTask)

Example 3 with ToolTask

use of tools.utils.ToolTask in project AuthMeReloaded by AuthMe.

the class ToolsRunner method main.

/**
     * Entry point of the runner.
     *
     * @param args .
     */
public static void main(String... args) {
    // Note ljacqu 20151212: If the tools folder becomes a lot bigger, it will make sense to restrict the depth
    // of this recursive collector
    ClassCollector collector = new ClassCollector(TestHelper.TEST_SOURCES_FOLDER, "tools");
    Map<String, ToolTask> tasks = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    for (ToolTask task : collector.getInstancesOfType(ToolTask.class)) {
        tasks.put(task.getTaskName(), task);
    }
    ToolsRunner runner = new ToolsRunner(tasks);
    if (args == null || args.length == 0) {
        runner.promptAndExecuteTask();
    } else {
        runner.executeAutomaticTasks(args);
    }
}
Also used : ToolTask(tools.utils.ToolTask) AutoToolTask(tools.utils.AutoToolTask) ClassCollector(fr.xephi.authme.ClassCollector) TreeMap(java.util.TreeMap)

Aggregations

AutoToolTask (tools.utils.AutoToolTask)3 ToolTask (tools.utils.ToolTask)3 ClassCollector (fr.xephi.authme.ClassCollector)1 Scanner (java.util.Scanner)1 TreeMap (java.util.TreeMap)1