common

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterValidArgs

func FilterValidArgs(valid, args []string, toComplete string) []string

FilterValidArgs filters the valid arguments and keeps only the ones that match the toComplete string and that are not present in args

Note: the result is a new slice, the original is not modified

func GetGitSection

func GetGitSection(ctx context.Context, reader io.Reader, name string) (section *ini.Section, err error)

GetGitSection returns the INI section from the git config file

func GetGitSectionsMatching

func GetGitSectionsMatching(ctx context.Context, reader io.Reader, rex *regexp.Regexp) (sections []*ini.Section, err error)

GetGitSectionsMatching returns the INI sections from the git config file matching the given regex

func NewCache

func NewCache[T any]() *cache.Cache[T]

func OpenGitConfig

func OpenGitConfig(ctx context.Context) (io.ReadCloser, error)

OpenGitConfig opens the .git/config file in the current folder or one of its parents

func Verbose

func Verbose(context context.Context, cmd *cobra.Command, format string, args ...any)

Verbose prints a message if the verbose flag is set

func WhatIf

func WhatIf(context context.Context, cmd *cobra.Command, format string, args ...any) (proceed bool)

WhatIf prints what would be done by the command

If the DryRun flag is set, it prints what would be done by the command and tells the caller to not proceed

otherwise it does nothing

Types

type Column

type Column[T any] struct {
	Name          string
	DefaultSorter bool
	Compare       func(a, b T) bool
}

type Columns

type Columns[T any] []Column[T]

func (Columns[T]) Columns

func (columns Columns[T]) Columns() []string

func (Columns[T]) SortBy

func (columns Columns[T]) SortBy(sorter string) func(a, b T) bool

func (Columns[T]) Sorters

func (columns Columns[T]) Sorters() []string

type Entity

type Entity struct {
	Type  string `json:"type"  mapstructure:"type"`
	ID    int    `json:"id"    mapstructure:"id"`
	Name  string `json:"name"  mapstructure:"name"`
	Links Links  `json:"links" mapstructure:"links"`
}

type ErrorProcessing

type ErrorProcessing int
const (
	StopOnError ErrorProcessing = iota
	WarnOnError
	IgnoreErrors
)

func (ErrorProcessing) CompletionFunc

func (ep ErrorProcessing) CompletionFunc() func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)

CompletionFunc returns the completion function of the ErrorProcessing

implements the pflag.Value interface

func (*ErrorProcessing) Set

func (ep *ErrorProcessing) Set(value string) error

Set sets the ErrorProcessing value

implements the pflag.Value interface

func (ErrorProcessing) String

func (ep ErrorProcessing) String() string

String returns the string representation of the ErrorProcessing

implements the fmt.Stringer interface

func (ErrorProcessing) Type

func (ep ErrorProcessing) Type() string

Type returns the type of the ErrorProcessing

implements the pflag.Value interface

func (ErrorProcessing) Values

func (ep ErrorProcessing) Values() []string

Values returns the allowed values of the ErrorProcessing

type FileAnchor

type FileAnchor struct {
	From uint64 `json:"from,omitempty" mapstructure:"from"`
	To   uint64 `json:"to,omitempty"   mapstructure:"to"`
	Path string `json:"path"           mapstructure:"path"`
}

func (FileAnchor) String

func (anchor FileAnchor) String() string

String gets a string representation of this FileAnchor

implements fmt.Stringer

type Link struct {
	Name   string  `json:"name,omitempty" mapstructure:"name"`
	HREF   url.URL `json:"-"`
	GitRef string  `json:"-"`
}

func (Link) MarshalJSON

func (link Link) MarshalJSON() (data []byte, err error)

MarshalJSON implements the json.Marshaler interface.

func (*Link) UnmarshalJSON

func (link *Link) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface.

type Links struct {
	Self           *Link  `json:"self,omitempty"            mapstructure:"self"`
	HTML           *Link  `json:"html,omitempty"            mapstructure:"html"`
	Avatar         *Link  `json:"avatar,omitempty"          mapstructure:"avatar"`
	Branches       *Link  `json:"branches,omitempty"        mapstructure:"branches"`
	Forks          *Link  `json:"forks,omitempty"           mapstructure:"forks"`
	Commits        *Link  `json:"commits,omitempty"         mapstructure:"commits"`
	PullRequests   *Link  `json:"pullrequests,omitempty"    mapstructure:"pullrequests"`
	Approve        *Link  `json:"approve,omitempty"         mapstructure:"approve"`
	RequestChanges *Link  `json:"request-changes,omitempty" mapstructure:"request-changes"`
	Diff           *Link  `json:"diff,omitempty"            mapstructure:"diff"`
	DiffStat       *Link  `json:"diffstat,omitempty"        mapstructure:"diffstat"`
	Patch          *Link  `json:"patch,omitempty"           mapstructure:"patch"`
	Comments       *Link  `json:"comments,omitempty"        mapstructure:"comments"`
	Activity       *Link  `json:"activity,omitempty"        mapstructure:"activity"`
	Merge          *Link  `json:"merge,omitempty"           mapstructure:"merge"`
	Decline        *Link  `json:"decline,omitempty"         mapstructure:"decline"`
	Statuses       *Link  `json:"statuses,omitempty"        mapstructure:"statuses"`
	Tags           *Link  `json:"tags,omitempty"            mapstructure:"tags"`
	Watchers       *Link  `json:"watchers,omitempty"        mapstructure:"watchers"`
	Downloads      *Link  `json:"downloads,omitempty"       mapstructure:"downloads"`
	Source         *Link  `json:"source,omitempty"          mapstructure:"source"`
	Clone          []Link `json:"clone,omitempty"           mapstructure:"clone"`
	Hooks          *Link  `json:"hooks,omitempty"           mapstructure:"hooks"`
	Steps          *Link  `json:"steps,omitempty"           mapstructure:"steps"`
}

func (Links) IsEmpty

func (links Links) IsEmpty() bool

IsEmpty tells if there is no link defined

type RenderedText

type RenderedText struct {
	Type   string `json:"type,omitempty"   mapstructure:"type"`
	Raw    string `json:"raw"              mapstructure:"raw"`
	Markup string `json:"markup,omitempty" mapstructure:"markup"` // markdown, creaole, plaintext
	HTML   string `json:"html,omitempty"   mapstructure:"html"`
}

type Selector

type Selector struct {
	Type    string `json:"type"              mapstructure:"type"`
	Pattern string `json:"pattern,omitempty" mapstructure:"pattern"`
}

Selector represents a selector for references (pipelines, branches, tags, etc.)

type Tableable

type Tableable interface {
	GetHeaders(cmd *cobra.Command) []string // GetHeaders retrieves the headers to show, use --columns flag or gives a default list
	GetRow(headers []string) []string       // GetRow retrieves the row to show for the given headers
}

Tableable is an interface for objects that can be printed as a table

type Tableables

type Tableables interface {
	GetHeaders(cmd *cobra.Command) []string        // GetHeaders retrieves the headers to show
	GetRowAt(index int, headers []string) []string // GetRow retrieves the row to show for the given headers
	Size() int                                     // Size gets the number of elements
}

Tableables is an interface for array of objects that can be printed as a table

type UUID

type UUID uuid.UUID

func NewUUID

func NewUUID() UUID

func ParseUUID

func ParseUUID(s string) (UUID, error)

func (UUID) IsNil

func (u UUID) IsNil() bool

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

func (UUID) String

func (u UUID) String() string

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(payload []byte) error

Jump to

Keyboard shortcuts

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