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 ¶
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
TokenAndLogin returns a token and its owner from one locked view of this source, so a refresh cannot split the pair across two credentials.