All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.devservices.deployment.DevServicesCommand Maven / Gradle / Ivy

package io.quarkus.devservices.deployment;

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import org.aesh.command.Command;
import org.aesh.command.CommandResult;
import org.aesh.command.GroupCommand;
import org.aesh.command.GroupCommandDefinition;
import org.aesh.command.invocation.CommandInvocation;

import io.quarkus.deployment.console.SetCompleter;
import io.quarkus.deployment.dev.devservices.DevServiceDescriptionBuildItem;

@GroupCommandDefinition(name = "devservices", description = "Dev Service Commands")
public class DevServicesCommand implements GroupCommand {
    static List serviceDescriptions;

    public DevServicesCommand(List serviceDescriptions) {
        DevServicesCommand.serviceDescriptions = serviceDescriptions;
    }

    @Override
    public List getCommands() {
        return List.of(new DevServicesListCommand(), new DevServicesLogsCommand());
    }

    @Override
    public CommandResult execute(CommandInvocation commandInvocation) {
        commandInvocation.println(commandInvocation.getHelpInfo());
        return CommandResult.SUCCESS;
    }

    static Optional findDevService(String devServiceName) {
        return serviceDescriptions.stream()
                .filter(d -> d.getName().equals(devServiceName))
                .findFirst();
    }

    public static class DevServiceCompleter extends SetCompleter {

        @Override
        protected Set allOptions(String soFar) {
            return serviceDescriptions.stream()
                    .map(DevServiceDescriptionBuildItem::getName)
                    .collect(Collectors.toSet());
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy