cmdutil

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFormatFlag added in v0.2.0

func AddFormatFlag(cmd *cobra.Command, format *string, jsonFlag *bool)

AddFormatFlag adds standard format and json flags to a command.

func FormatAndStream added in v0.4.0

func FormatAndStream[T any](f *Factory, results <-chan api.Result[T], outputFormat formatter.OutputFormat, limit int, entityName string) error

FormatAndStream handles the streaming output pattern common to list commands. It converts a Result channel to the streaming formatter output.

Types

type Factory

type Factory struct {
	IOStreams *iostreams.IOStreams
	Config    func() (*config.Config, error)
	Client    func() (*api.Client, error)
	Remote    func() (*git.Remote, error)
	Version   string
	// contains filtered or unexported fields
}

Factory provides shared dependencies for commands.

func NewFactory

func NewFactory() *Factory

NewFactory creates a Factory with default implementations.

func (*Factory) FormatAndPrint added in v0.2.0

func (f *Factory) FormatAndPrint(data interface{}, format string, jsonFlag bool) error

FormatAndPrint formats and prints data according to format flags. It handles backward compatibility for the --json flag.

func (*Factory) FullProjectPath

func (f *Factory) FullProjectPath() (string, error)

FullProjectPath returns the "owner/repo" path from the current git remote, or from the --repo override if set.

func (*Factory) GetHostVersion added in v0.2.0

func (f *Factory) GetHostVersion(host string) string

GetHostVersion returns the cached GitLab version for a given host. Returns empty string if version is unknown or not cached (graceful degradation).

func (*Factory) GetOutputFormat added in v0.2.0

func (f *Factory) GetOutputFormat() string

GetOutputFormat returns the current output format.

func (*Factory) IsJSONFormat added in v0.2.0

func (f *Factory) IsJSONFormat() bool

IsJSONFormat returns true if the output format is JSON.

func (*Factory) ResolveFormat added in v0.4.0

func (f *Factory) ResolveFormat(format string, jsonFlag bool) (formatter.OutputFormat, error)

ResolveFormat resolves the output format from the format string and deprecated --json flag. It returns the validated OutputFormat and an error if the format is invalid. If jsonFlag is true, a deprecation warning is printed to stderr.

func (*Factory) SetOutputFormat added in v0.2.0

func (f *Factory) SetOutputFormat(format string)

SetOutputFormat sets the output format for the command execution. This is used to determine how errors should be formatted.

func (*Factory) SetRepoOverride added in v0.0.9

func (f *Factory) SetRepoOverride(repo string)

SetRepoOverride parses a HOST/OWNER/REPO string and stores it.

Jump to

Keyboard shortcuts

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