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

io.quarkiverse.githubapp.command.airline.AbstractHelpCommand Maven / Gradle / Ivy

There is a newer version: 2.8.2
Show newest version
package io.quarkiverse.githubapp.command.airline;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

import org.kohsuke.github.GHEventPayload;

import com.github.rvesse.airline.annotations.Arguments;
import com.github.rvesse.airline.help.Help;
import com.github.rvesse.airline.model.GlobalMetadata;

public class AbstractHelpCommand {

    @AirlineInject
    public GlobalMetadata global;

    @Arguments
    public List command = new ArrayList<>();

    public void run(GHEventPayload.IssueComment issueCommentPayload) throws IOException {
        try {
            ByteArrayOutputStream helpOs = new ByteArrayOutputStream();
            Help.help(global, command, helpOs);

            issueCommentPayload.getIssue().comment("```\n" + helpOs.toString(StandardCharsets.UTF_8).trim() + "\n```");
        } catch (IOException e) {
            throw new RuntimeException("Error generating usage documentation for " + String.join(" ", command), e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy