Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Say Hello CLI - playing around #41

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -44,6 +44,11 @@
<artifactId>quarkus-github-app</artifactId>
<version>${quarkus-github-app.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.githubapp</groupId>
<artifactId>quarkus-github-app-command-airline</artifactId>
<version>${quarkus-github-app.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.expressly</groupId>
<artifactId>expressly</artifactId>
32 changes: 32 additions & 0 deletions src/main/java/dev/langchain4j/automation/SayHelloCli.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package dev.langchain4j.automation;

import com.github.rvesse.airline.annotations.Cli;
import com.github.rvesse.airline.annotations.Command;
import org.kohsuke.github.GHEventPayload;
import org.kohsuke.github.GHUser;

import java.io.IOException;

@Cli(name = "@langchain4j-github-bot", commands = { SayHelloCli.SayHello.class })
public class SayHelloCli {

interface Commands {

void run(GHEventPayload.IssueComment issueCommentPayload) throws IOException;
}

@Command(name = "sayHello")
static class SayHello implements Commands {

@Override
public void run(GHEventPayload.IssueComment issueCommentPayload) throws IOException {
// TODO check permissions
GHUser sender = issueCommentPayload.getSender();
Comment on lines +23 to +24
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can automatically check permissions with annotations: https://docs.quarkiverse.io/quarkus-github-app/dev/commands.html#permissions

if (sender != null && sender.getLogin() != null) {
issueCommentPayload.getIssue().comment("Hello, @" + sender.getLogin());
} else {
issueCommentPayload.getIssue().comment("Hello stranger!");
}
}
}
}