context

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLoginByEnvVar added in v0.11.0

func GetLoginByEnvVar() *config.Login

GetLoginByEnvVar returns a login based on environment variables, or nil if no login can be created

func MatchLogins added in v0.11.1

func MatchLogins(remoteURL string, logins []config.Login) (*config.Login, string, error)

MatchLogins matches the given remoteURL against the provided logins and returns the first matching login remoteURL could be like:

https://gitea.com/owner/repo.git
http://gitea.com/owner/repo.git
ssh://gitea.com/owner/repo.git
git@gitea.com:owner/repo.git

Types

type CtxRequirement

type CtxRequirement struct {
	// ensures a local git repo is available & ctx.LocalRepo is set. Implies .RemoteRepo
	LocalRepo bool
	// ensures ctx.RepoSlug, .Owner, .Repo are set
	RemoteRepo bool
	// ensures ctx.Org is set
	Org bool
	// ensures ctx.IsGlobal is true
	Global bool
}

CtxRequirement specifies context needed for operation

type TeaContext

type TeaContext struct {
	*cli.Command
	Login     *config.Login // config data & client for selected login
	RepoSlug  string        // <owner>/<repo>, optional
	Owner     string        // repo owner as derived from context or provided in flag, optional
	Repo      string        // repo name as derived from context or provided in flag, optional
	Org       string        // organization name, optional
	IsGlobal  bool          // true if operating on global level
	Output    string        // value of output flag
	LocalRepo *git.TeaRepo  // is set if flags specified a local repo via --repo, or if $PWD is a git repo
}

TeaContext contains all context derived during command initialization and wraps cli.Context

func InitCommand

func InitCommand(cmd *cli.Command) *TeaContext

InitCommand resolves the application context, and returns the active login, and if available the repo slug. It does this by reading the config file for logins, parsing the remotes of the .git repo specified in repoFlag or $PWD, and using overrides from command flags. If a local git repo can't be found, repo slug values are unset.

func (*TeaContext) Ensure

func (ctx *TeaContext) Ensure(req CtxRequirement)

Ensure checks if requirements on the context are set, and terminates otherwise.

func (*TeaContext) GetRemoteRepoHTMLURL added in v0.10.0

func (ctx *TeaContext) GetRemoteRepoHTMLURL() string

GetRemoteRepoHTMLURL returns the web-ui url of the remote repo, after ensuring a remote repo is present in the context.

func (*TeaContext) IsInteractiveMode added in v0.12.0

func (ctx *TeaContext) IsInteractiveMode() bool

IsInteractiveMode returns true if the command is running in interactive mode (no flags provided and stdout is a terminal)

Jump to

Keyboard shortcuts

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