Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k1low/viagh
:octocat: http.Client that makes API requests via the `gh` command
https://github.com/k1low/viagh
github github-api golang
Last synced: 29 days ago
JSON representation
:octocat: http.Client that makes API requests via the `gh` command
- Host: GitHub
- URL: https://github.com/k1low/viagh
- Owner: k1LoW
- License: mit
- Created: 2021-11-10T03:33:40.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-24T19:09:43.000Z (almost 3 years ago)
- Last Synced: 2024-10-06T04:16:45.559Z (about 1 month ago)
- Topics: github, github-api, golang
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# viagh [![build](https://github.com/k1LoW/viagh/actions/workflows/ci.yml/badge.svg)](https://github.com/k1LoW/viagh/actions/workflows/ci.yml) [![Go Reference](https://pkg.go.dev/badge/github.com/k1LoW/viagh.svg)](https://pkg.go.dev/github.com/k1LoW/viagh)
:octocat: `viagh.NewHTTPClient` returns a `*http.Client` that makes API requests via the `gh` command.
## Why viagh?
When writing a GitHub CLI extension, the extension needs to exec the `gh` command internally to execute API requests with credentials.
By using `http.Client` that executes API requests via the `gh` command, you can use existing useful packages such as [go-github](https://github.com/google/go-github) without modification.
## Usage
``` go
package mainimport (
"context"
"fmt""github.com/google/go-github/v39/github"
"github.com/k1LoW/viagh"
)func main() {
ctx := context.Background()
client, _ := viagh.NewHTTPClient()
gh := github.NewClient(client)u, _, _ := gh.Users.Get(ctx, "k1LoW")
fmt.Println(u.GetLogin())
}
```