Search in sources :

Example 6 with LinePrefixingStyledTextOutput

use of org.gradle.internal.logging.text.LinePrefixingStyledTextOutput in project gradle by gradle.

the class TaskDetailPrinter method printlnCommandlineOptions.

private void printlnCommandlineOptions(StyledTextOutput output, List<Task> tasks) {
    List<OptionDescriptor> allOptions = new ArrayList<OptionDescriptor>();
    for (Task task : tasks) {
        allOptions.addAll(optionReader.getOptions(task));
    }
    if (!allOptions.isEmpty()) {
        output.println();
        output.text("Options").println();
    }
    Map<String, Set<String>> optionToAvailableOptionsValues = optionToAvailableValues(allOptions);
    Map<String, String> optionToDescription = optionToDescription(allOptions);
    Iterator<String> optionNames = optionToAvailableOptionsValues.keySet().iterator();
    while (optionNames.hasNext()) {
        String currentOption = optionNames.next();
        Set<String> availableValues = optionToAvailableOptionsValues.get(currentOption);
        String optionString = "--" + currentOption;
        output.text(INDENT).withStyle(UserInput).text(optionString);
        output.text(INDENT).text(optionToDescription.get(currentOption));
        if (!availableValues.isEmpty()) {
            final int optionDescriptionOffset = 2 * INDENT.length() + optionString.length();
            final LinePrefixingStyledTextOutput prefixedOutput = createIndentedOutput(output, optionDescriptionOffset);
            prefixedOutput.println();
            prefixedOutput.println("Available values are:");
            for (String value : availableValues) {
                prefixedOutput.text(INDENT);
                prefixedOutput.withStyle(UserInput).println(value);
            }
        } else {
            output.println();
        }
        if (optionNames.hasNext()) {
            output.println();
        }
    }
}
Also used : Task(org.gradle.api.Task) DefaultTask(org.gradle.api.DefaultTask) OptionDescriptor(org.gradle.api.internal.tasks.options.OptionDescriptor) LinePrefixingStyledTextOutput(org.gradle.internal.logging.text.LinePrefixingStyledTextOutput)

Aggregations

LinePrefixingStyledTextOutput (org.gradle.internal.logging.text.LinePrefixingStyledTextOutput)6 DefaultTask (org.gradle.api.DefaultTask)3 Task (org.gradle.api.Task)3 StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)2 OptionDescriptor (org.gradle.api.internal.tasks.options.OptionDescriptor)1 LocationAwareException (org.gradle.internal.exceptions.LocationAwareException)1 AbstractStyledTextOutput (org.gradle.internal.logging.text.AbstractStyledTextOutput)1