execenv

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const RootCommandName = "git-bug"

Variables

This section is empty.

Functions

func CacheBuildProgressBar

func CacheBuildProgressBar(env *Env, events chan cache.BuildEvent) error

func CloseBackend

func CloseBackend(env *Env, runE func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string) error

CloseBackend is a wrapper for a RunE function that will close the Backend properly if it has been opened. This wrapper style is necessary because a Cobra PostE function does not run if RunE return an error.

func LoadBackend

func LoadBackend(env *Env) func(*cobra.Command, []string) error

LoadBackend is a pre-run function that load the repository and the Backend for use in a command When using this function you also need to use CloseBackend as a post-run

func LoadBackendEnsureUser

func LoadBackendEnsureUser(env *Env) func(*cobra.Command, []string) error

LoadBackendEnsureUser is the same as LoadBackend, but also ensure that the user has configured an identity. Use this pre-run function when an error after using the configured user won't do.

func LoadRepo

func LoadRepo(env *Env) func(*cobra.Command, []string) error

LoadRepo is a pre-run function that load the repository for use in a command

func LoadRepoEnsureUser

func LoadRepoEnsureUser(env *Env) func(*cobra.Command, []string) error

LoadRepoEnsureUser is the same as LoadRepo, but also ensure that the user has configured an identity. Use this pre-run function when an error after using the configured user won't do.

Types

type Env

type Env struct {
	Repo    repository.ClockedRepo
	Backend *cache.RepoCache
	In      In
	Out     Out
	Err     Out
}

Env is the environment of a command

func NewEnv

func NewEnv() *Env

func NewTestEnv

func NewTestEnv(t *testing.T) *Env

func NewTestEnvTerminal

func NewTestEnvTerminal(t *testing.T) *Env

type In

type In interface {
	io.Reader

	// IsTerminal tells if the input is a user terminal (rather than a buffer,
	// a pipe ...), which tells if we can use interactive features.
	IsTerminal() bool

	// ForceIsTerminal allow to force the returned value of IsTerminal
	// This only works in test scenario.
	ForceIsTerminal(value bool)
}

type Out

type Out interface {
	io.Writer

	Printf(format string, a ...interface{})
	Print(a ...interface{})
	Println(a ...interface{})
	PrintJSON(v interface{}) error

	// IsTerminal tells if the output is a user terminal (rather than a buffer,
	// a pipe ...), which tells if we can use colors and other interactive features.
	IsTerminal() bool
	// Width return the width of the attached terminal, or a good enough value.
	Width() int

	// Raw return the underlying io.Writer, or itself if not.
	// This is useful if something need to access the raw file descriptor.
	Raw() io.Writer

	// String returns what have been written in the output before, as a string.
	// This only works in test scenario.
	String() string
	// Bytes returns what have been written in the output before, as []byte.
	// This only works in test scenario.
	Bytes() []byte
	// Reset clear what has been recorded as written in the output before.
	// This only works in test scenario.
	Reset()
	// ForceIsTerminal allow to force the returned value of IsTerminal
	// This only works in test scenario.
	ForceIsTerminal(value bool)
}

type TestIn

type TestIn struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

func (*TestIn) ForceIsTerminal

func (t *TestIn) ForceIsTerminal(value bool)

func (*TestIn) IsTerminal

func (t *TestIn) IsTerminal() bool

type TestOut

type TestOut struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

func (*TestOut) ForceIsTerminal

func (te *TestOut) ForceIsTerminal(value bool)

func (*TestOut) IsTerminal

func (te *TestOut) IsTerminal() bool

func (*TestOut) Print

func (te *TestOut) Print(a ...interface{})

func (*TestOut) PrintJSON

func (te *TestOut) PrintJSON(v interface{}) error

func (*TestOut) Printf

func (te *TestOut) Printf(format string, a ...interface{})

func (*TestOut) Println

func (te *TestOut) Println(a ...interface{})

func (*TestOut) Raw

func (te *TestOut) Raw() io.Writer

func (*TestOut) Width

func (te *TestOut) Width() int

Jump to

Keyboard shortcuts

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