Giter Site home page Giter Site logo

go-gh's Introduction

go-gh beta

This project is in beta! Feedback is welcome.

A Go module for CLI Go applications and gh extensions that want a convenient way to interact with gh, and the GitHub API using gh environment configuration.

go-gh supports multiple ways of getting access to gh functionality:

  • Helpers that automatically read a gh config to authenticate themselves
  • gh.Exec shells out to a gh install on your machine

If you'd like to use go-gh on systems without gh installed and configured, you can provide custom authentication details to the go-gh API helpers.

Installation

go get github.com/cli/go-gh

Usage

package main
import (
	"fmt"
	"github.com/cli/go-gh"
)

func main() {
	// These examples assume `gh` is installed and has been authenticated

	// Execute `gh issue list -R cli/cli`, and print the output.
	args := []string{"issue", "list", "-R", "cli/cli"}
	stdOut, _, err := gh.Exec(args...)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(stdOut.String())
	
	// Use an API helper to grab repository tags
	client, err := gh.RESTClient(nil)
	if err != nil {
		fmt.Println(err)
		return
	}
	response := []struct{ Name string }{}
	err = client.Get("repos/cli/cli/tags", &response)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(response)
}

See examples for more use cases.

Reference Documentation

Full reference docs can be found on pkg.go.dev.

Contributing

If anything feels off, or if you feel that some functionality is missing, please check out the contributing page. There you will find instructions for sharing your feedback, and submitting pull requests to the project.

go-gh's People

Contributors

devonhk avatar samcoe avatar shawnps avatar sridharavinash avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.