Class GitHubCli
java.lang.Object
io.github.intisy.gradle.github.impl.GitHubCli
Routes GitHub REST calls through the local
gh CLI (gh api ...) instead of direct HTTP.
The CLI supplies its own authentication and higher (authenticated) rate limits, so no access token
needs to be configured. Each call is adapted back into an OkHttp Response so the surrounding
response-handling and JSON parsing in GitHub stay unchanged.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether theghCLI is installed and runnable.okhttp3.ResponsePerforms a GitHub REST request viagh apiand adapts the result into an OkHttpResponse.
-
Constructor Details
-
GitHubCli
- Parameters:
logger- the logger for diagnostics.
-
-
Method Details
-
isAvailable
public boolean isAvailable()Checks whether theghCLI is installed and runnable. The result is probed once and cached.- Returns:
- true if
gh --versionsucceeds.
-
request
Performs a GitHub REST request viagh apiand adapts the result into an OkHttpResponse.- Parameters:
url- the full GitHub API URL (also accepted as a bare path bygh api).method- the HTTP method, e.g."GET"or"POST".jsonBody- the JSON request body for writes, or null for reads.- Returns:
- a synthetic
Responsecarrying the CLI's status code and body. - Throws:
IOException- if the CLI process cannot be started or its I/O fails.
-