cmdutil

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddForceFlag

func AddForceFlag(cmd *cobra.Command, force *bool)

AddForceFlag adds the --force/-f flag to a command.

func AddOutputFlag

func AddOutputFlag(cmd *cobra.Command, format *string)

AddOutputFlag adds the --output/-o flag to a command.

func AddPaginationFlags

func AddPaginationFlags(cmd *cobra.Command, limit, offset *int)

AddPaginationFlags adds --limit and --offset flags to a command.

func ConfirmAction

func ConfirmAction(in io.Reader, errOut io.Writer, message string) bool

ConfirmAction prompts the user to confirm a destructive action. Returns true if the user confirms with "y" or "yes". If in is not interactive or the user declines, returns false.

func FormatError

func FormatError(err error) string

FormatError converts an API error into a user-friendly message.

func ResolveProjectID added in v1.10.1

func ResolveProjectID(ctx context.Context, f *Factory, input string) (string, error)

ResolveProjectID resolves a project input to its numeric ID string.

func ResolveProjectIdentifier added in v1.10.1

func ResolveProjectIdentifier(ctx context.Context, f *Factory, input string) (string, error)

ResolveProjectIdentifier resolves a project input to its canonical identifier.

Types

type Factory

type Factory struct {
	ConfigPath string
	Verbose    bool

	IOStreams *IOStreams
	// contains filtered or unexported fields
}

Factory provides lazy access to configuration, API client, and output printer.

func NewFactory

func NewFactory() *Factory

NewFactory creates a new Factory with default I/O streams.

func (*Factory) ApiClient

func (f *Factory) ApiClient() (*api.Client, error)

ApiClient returns an API client (cached after first call).

func (*Factory) Config

func (f *Factory) Config() (*config.Config, error)

Config returns the loaded configuration (cached after first call).

func (*Factory) DebugLogger

func (f *Factory) DebugLogger() *debug.Logger

DebugLogger returns the debug logger, creating it on first call.

func (*Factory) Printer

func (f *Factory) Printer(format string) output.Printer

Printer returns the output printer.

type IOStreams

type IOStreams struct {
	In     io.Reader
	Out    io.Writer
	ErrOut io.Writer
	IsTTY  bool
}

IOStreams holds the standard I/O streams.

type SilentError added in v1.10.0

type SilentError struct{ Code int }

SilentError is returned when the error message has already been printed or should be suppressed. main.go will still exit with the given code.

func (*SilentError) Error added in v1.10.0

func (e *SilentError) Error() string

Jump to

Keyboard shortcuts

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