cli/go-gh
关于
用于在命令行中与 gh 和 GitHub API 交互的 Go 模块。
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Go library for the GitHub CLI
go-gh is a collection of Go modules to make authoring GitHub CLI extensions easier.
Modules from this library will obey GitHub CLI conventions by default:
repository.Current()respects the value of theGH_REPOenvironment variable and reads from git remote configuration as fallback.GitHub API requests will be authenticated using the same mechanism as
gh, i.e. using the values ofGH_TOKENandGH_HOSTenvironment variables and falling back to the user's stored OAuth token.Terminal capabilities are determined by taking environment variables
GH_FORCE_TTY,NO_COLOR,CLICOLOR, etc. into account.Generating table or Go template output uses the same engine as gh.
The
browsermodule activates the user's preferred web browser.
Usage
See the full go-gh reference documentation for more information
package main
import (
"fmt"
"log"
"github.com/cli/go-gh/v2"
"github.com/cli/go-gh/v2/pkg/api"
)
func main() {
// These examples assume `gh` is installed and has been authenticated.
// Shell out to a gh command and read its output.
issueList, _, err := gh.Exec("issue", "list", "--repo", "cli/cli", "--limit", "5")
if err != nil {
log.Fatal(err)
}
fmt.Println(issueList.String())
// Use an API client to retrieve repository tags.
client, err := api.DefaultRESTClient()
if err != nil {
log.Fatal(err)
}
response := []struct{
Name string
}{}
err = client.Get("repos/cli/cli/tags", &response)
if err != nil {
log.Fatal(err)
}
fmt.Println(response)
}
See examples for more demonstrations of usage.
Contributing
If anything feels off, or if you feel that some functionality is missing, please check out our contributing docs. There you will find instructions for sharing your feedback and for submitting pull requests to the project. Thank you!
探索相关项目
加载中…