Documentation
¶
Index ¶
- func AddFormatFlag(cmd *cobra.Command, format *string, jsonFlag *bool)
- func FormatAndStream[T any](f *Factory, results <-chan api.Result[T], outputFormat formatter.OutputFormat, ...) error
- type Factory
- func (f *Factory) FormatAndPrint(data interface{}, format string, jsonFlag bool) error
- func (f *Factory) FullProjectPath() (string, error)
- func (f *Factory) GetHostVersion(host string) string
- func (f *Factory) GetOutputFormat() string
- func (f *Factory) IsJSONFormat() bool
- func (f *Factory) ResolveFormat(format string, jsonFlag bool) (formatter.OutputFormat, error)
- func (f *Factory) SetOutputFormat(format string)
- func (f *Factory) SetRepoOverride(repo string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFormatFlag ¶ added in v0.2.0
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
FormatAndPrint formats and prints data according to format flags. It handles backward compatibility for the --json flag.
func (*Factory) FullProjectPath ¶
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
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
GetOutputFormat returns the current output format.
func (*Factory) IsJSONFormat ¶ added in v0.2.0
IsJSONFormat returns true if the output format is JSON.
func (*Factory) ResolveFormat ¶ added in v0.4.0
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
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
SetRepoOverride parses a HOST/OWNER/REPO string and stores it.