context

package
v0.7.1-0...-009166e Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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
}

CtxRequirement specifies context needed for operation

type TeaContext

type TeaContext struct {
	*cli.Context
	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
	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(ctx *cli.Context) *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) GetListOptions

func (ctx *TeaContext) GetListOptions() gitea.ListOptions

GetListOptions return ListOptions based on PaginationFlags

Jump to

Keyboard shortcuts

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