ctxutil

package
v1.15.14 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 6 Imported by: 208

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCallback = fmt.Errorf("no callback")

ErrNoCallback is returned when no callback is set in the context.

Functions

func AddToCommitMessageBody added in v1.15.3

func AddToCommitMessageBody(ctx context.Context, sv string) context.Context

AddToCommitMessageBody returns a context with something added to the commit's body.

func GetAlias

func GetAlias(ctx context.Context) string

GetAlias returns an alias if it has been set or an empty string otherwise.

func GetCommitMessage

func GetCommitMessage(ctx context.Context) string

GetCommitMessage returns the set commit message (head) or an empty string.

func GetCommitMessageBody added in v1.15.3

func GetCommitMessageBody(ctx context.Context) string

GetCommitMessageBody returns the set commit message body or an empty string.

func GetCommitMessageFull added in v1.15.3

func GetCommitMessageFull(ctx context.Context) string

GetCommitMessageFull returns the set commit message (head+body, of either are defined) or an empty string.

func GetCommitTimestamp

func GetCommitTimestamp(ctx context.Context) time.Time

GetCommitTimestamp returns the commit timestamp from the context if set or the default (now) otherwise.

func GetEmail

func GetEmail(ctx context.Context) string

GetEmail returns the email from the context.

func GetImportFunc

func GetImportFunc(ctx context.Context) store.ImportCallback

GetImportFunc will return the import callback or a default one returning true Note: will never return nil.

func GetUsername

func GetUsername(ctx context.Context) string

GetUsername returns the username from the context.

func HasAlias

func HasAlias(ctx context.Context) bool

HasAlias returns true if a value for alias has been set.

func HasAlwaysYes

func HasAlwaysYes(ctx context.Context) bool

HasAlwaysYes returns true if a value for AlwaysYes has been set in this context.

func HasCommitMessage

func HasCommitMessage(ctx context.Context) bool

HasCommitMessage returns true if the commit message (head) was set.

func HasCommitMessageBody added in v1.15.3

func HasCommitMessageBody(ctx context.Context) bool

HasCommitMessageBody returns true if the commit message body is nonempty.

func HasCommitTimestamp

func HasCommitTimestamp(ctx context.Context) bool

HasCommitTimestamp returns true if the value for the commit timestamp was set in the context.

func HasForce

func HasForce(ctx context.Context) bool

HasForce returns true if the context has the force flag set.

func HasGitCommit

func HasGitCommit(ctx context.Context) bool

HasGitCommit returns true if a value for GitCommit has been set in this context.

func HasGitInit

func HasGitInit(ctx context.Context) bool

HasGitInit returns true if the git init flag was set.

func HasImportFunc

func HasImportFunc(ctx context.Context) bool

HasImportFunc returns true if a value for import func has been set in this context.

func HasInteractive

func HasInteractive(ctx context.Context) bool

HasInteractive returns true if a value for Interactive has been set in this context.

func HasNoNetwork

func HasNoNetwork(ctx context.Context) bool

HasNoNetwork returns true if no network was set.

func HasPasswordCallback

func HasPasswordCallback(ctx context.Context) bool

HasPasswordCallback returns true if a password callback was set in the context.

func HasPasswordPurgeCallback added in v1.14.5

func HasPasswordPurgeCallback(ctx context.Context) bool

HasPasswordPurgeCallback returns true if a password purge callback was set in the context.

func HasProgressCallback

func HasProgressCallback(ctx context.Context) bool

HasProgressCallback returns true if a ProgressCallback has been set.

func HasShowParsing

func HasShowParsing(ctx context.Context) bool

HasShowParsing returns true if a value for ShowParsing has been set in this context.

func HasStdin

func HasStdin(ctx context.Context) bool

HasStdin returns true if a value for Stdin has been set in this context.

func HasTerminal

func HasTerminal(ctx context.Context) bool

HasTerminal returns true if a value for Terminal has been set in this context.

func IsAlwaysYes

func IsAlwaysYes(ctx context.Context) bool

IsAlwaysYes returns the value of always yes or the default (false).

func IsForce

func IsForce(ctx context.Context) bool

IsForce returns the force flag value of the default (false).

func IsGitCommit

func IsGitCommit(ctx context.Context) bool

IsGitCommit returns the value of git commit or the default (true).

func IsGitInit

func IsGitInit(ctx context.Context) bool

IsGitInit returns the value of the git init flag or ture if none was set.

func IsHidden

func IsHidden(ctx context.Context) bool

IsHidden returns true if any output should be hidden in this context.

func IsInteractive

func IsInteractive(ctx context.Context) bool

IsInteractive returns the value of interactive or the default (true).

func IsNoNetwork

func IsNoNetwork(ctx context.Context) bool

IsNoNetwork returns the value of no network or false.

func IsShowParsing

func IsShowParsing(ctx context.Context) bool

IsShowParsing returns the value of ShowParsing or the default (true).

func IsStdin

func IsStdin(ctx context.Context) bool

IsStdin returns the value of stdin, i.e. if it's true some data is being piped to stdin. If not set it returns the default value (false).

func IsTerminal

func IsTerminal(ctx context.Context) bool

IsTerminal returns the value of terminal or the default (true).

func WithAlias

func WithAlias(ctx context.Context, alias string) context.Context

WithAlias returns an context with the alias set.

func WithAlwaysYes

func WithAlwaysYes(ctx context.Context, bv bool) context.Context

WithAlwaysYes returns a context with the value of always yes set.

func WithCommitMessage

func WithCommitMessage(ctx context.Context, sv string) context.Context

WithCommitMessage returns a context with a commit message (head) set. (full commit message is the commit message's body is not defined, commit message head otherwise).

func WithCommitTimestamp

func WithCommitTimestamp(ctx context.Context, ts time.Time) context.Context

WithCommitTimestamp returns a context with the value for the commit timestamp set.

func WithEmail

func WithEmail(ctx context.Context, sv string) context.Context

WithEmail returns a context with the email set in the context.

func WithForce

func WithForce(ctx context.Context, bv bool) context.Context

WithForce returns a context with the force flag set.

func WithGitCommit

func WithGitCommit(ctx context.Context, bv bool) context.Context

WithGitCommit returns a context with the value of git commit set.

func WithGitInit

func WithGitInit(ctx context.Context, bv bool) context.Context

WithGitInit returns a context with the value for the git init flag set.

func WithGlobalFlags

func WithGlobalFlags(c *cli.Context) context.Context

WithGlobalFlags parses any global flags from the cli context and returns a regular context.

func WithHidden

func WithHidden(ctx context.Context, hidden bool) context.Context

WithHidden returns a context with the flag value for hidden set.

func WithImportFunc

func WithImportFunc(ctx context.Context, imf store.ImportCallback) context.Context

WithImportFunc will return a context with the import callback set.

func WithInteractive

func WithInteractive(ctx context.Context, isInteractive bool) context.Context

WithInteractive returns a context with an explicit value for interactive.

func WithNoNetwork

func WithNoNetwork(ctx context.Context, bv bool) context.Context

WithNoNetwork returns a context with the value of no network set.

func WithPasswordCallback

func WithPasswordCallback(ctx context.Context, cb PasswordCallback) context.Context

WithPasswordCallback returns a context with the password callback set.

func WithPasswordPurgeCallback added in v1.14.5

func WithPasswordPurgeCallback(ctx context.Context, cb PasswordPurgeCallback) context.Context

WithPasswordPurgeCallback returns a context with the password purge callback set.

func WithProgressCallback

func WithProgressCallback(ctx context.Context, cb ProgressCallback) context.Context

WithProgressCallback returns a context with the value of ProgressCallback set.

func WithShowParsing

func WithShowParsing(ctx context.Context, bv bool) context.Context

WithShowParsing returns a context with the value for ShowParsing set.

func WithStdin

func WithStdin(ctx context.Context, isStdin bool) context.Context

WithStdin returns a context with the value for Stdin set. If true some input is available on Stdin (e.g. something is being piped into it).

func WithTerminal

func WithTerminal(ctx context.Context, isTerm bool) context.Context

WithTerminal returns a context with an explicit value for terminal.

func WithUsername

func WithUsername(ctx context.Context, sv string) context.Context

WithUsername returns a context with the username set in the context.

Types

type HeadedText added in v1.15.3

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

func (*HeadedText) AddToBody added in v1.15.3

func (h *HeadedText) AddToBody(s string)

func (*HeadedText) ClearBody added in v1.15.3

func (h *HeadedText) ClearBody()

func (*HeadedText) GetBody added in v1.15.3

func (h *HeadedText) GetBody() string

func (*HeadedText) GetHead added in v1.15.3

func (h *HeadedText) GetHead() string

func (*HeadedText) GetText added in v1.15.3

func (h *HeadedText) GetText() string

func (*HeadedText) HasBody added in v1.15.3

func (h *HeadedText) HasBody() bool

func (*HeadedText) SetHead added in v1.15.3

func (h *HeadedText) SetHead(s string)

type PasswordCallback

type PasswordCallback func(string, bool) ([]byte, error)

PasswordCallback is a password prompt callback.

func GetPasswordCallback

func GetPasswordCallback(ctx context.Context) PasswordCallback

GetPasswordCallback returns the password callback or a default (which always fails).

type PasswordPurgeCallback added in v1.14.5

type PasswordPurgeCallback func(string)

PasswordPurgeCallback is a callback to purge a password cached by PasswordCallback.

func GetPasswordPurgeCallback added in v1.14.5

func GetPasswordPurgeCallback(ctx context.Context) PasswordPurgeCallback

GetPasswordPurgeCallback returns the password purge callback or a default (which is a no-op).

type ProgressCallback

type ProgressCallback func()

ProgressCallback is a callback for updateing progress.

func GetProgressCallback

func GetProgressCallback(ctx context.Context) ProgressCallback

GetProgressCallback return the set progress callback or a default one. It never returns nil.

Jump to

Keyboard shortcuts

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