ghcli

package
v0.55.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ghcli provides access to the local GitHub CLI (gh) for authentication and lightweight command execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login

func Login(ctx context.Context) (string, error)

Login returns the login of the currently authenticated GitHub user using the package's default token source. Callers that need an independent credential source should create a TokenSource and use its Login method.

func Run

func Run(ctx context.Context, args ...string) (string, error)

Run executes `gh` with the given arguments and returns its stdout. The gh binary name is fixed and arguments are supplied by aeman itself, never by untrusted input.

Types

type TokenSource

type TokenSource struct {
	// contains filtered or unexported fields
}

TokenSource resolves a GitHub token from the local gh CLI and caches it. It is also the GitHub side of forge.CLI: the token plus the signed-in login.

func NewTokenSource

func NewTokenSource() *TokenSource

NewTokenSource returns a TokenSource backed by `gh auth token`.

func (*TokenSource) Login added in v0.26.0

func (t *TokenSource) Login(ctx context.Context) (string, error)

Login returns the login belonging to the source's current token. It is cached per TokenSource and per token so replacing the gh credential makes a running process refresh the identity on the same schedule as the token.

func (*TokenSource) Token

func (t *TokenSource) Token(ctx context.Context) (string, error)

Token returns a cached GitHub token, fetching a fresh one when the cache has expired. It returns an error if gh is missing or the user is not logged in.

func (*TokenSource) TokenAndLogin added in v0.41.7

func (t *TokenSource) TokenAndLogin(ctx context.Context) (string, string, error)

TokenAndLogin returns a token and its owner from one locked view of this source, so a refresh cannot split the pair across two credentials.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL