cmdutil

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSilent  = errors.New("silent")
	ErrPending = errors.New("pending")
)

Functions

func ClientFromCmd added in v0.1.4

func ClientFromCmd(f *Factory, cmd *cobra.Command) (*iostreams.IOStreams, *magento.Client, error)

ClientFromCmd resolves the active context, applies any --store-code override, and constructs a Magento client. It collapses the boilerplate every command otherwise repeats and guarantees --store-code is honored uniformly.

func FlagValue

func FlagValue(cmd *cobra.Command, name string) string

FlagValue returns the value for the named flag if it exists.

func HostKeyFromURL

func HostKeyFromURL(baseURL string) (string, error)

func NewHTTPClient

func NewHTTPClient(host *config.Host, storeCode string) (*httpx.Client, error)

NewHTTPClient constructs a raw HTTP client for the configured host.

func NewMagentoClient

func NewMagentoClient(host *config.Host, storeCode string) (*magento.Client, error)

NewMagentoClient constructs a Magento API client from the resolved context.

func NormalizeBaseURL

func NormalizeBaseURL(raw string) (string, error)

func NotImplemented

func NotImplemented(cmd *cobra.Command) error

func ResolveContext

func ResolveContext(f *Factory, cmd *cobra.Command, override string) (string, *config.Context, *config.Host, error)

ResolveContext fetches the context and host configuration given an optional override name (typically provided via --context).

func ResolveHost

func ResolveHost(f *Factory, contextOverride, hostOverride string) (string, *config.Host, error)

ResolveHost locates a host configuration using optional context or host overrides.

func StoreCodeFromCmd added in v0.1.4

func StoreCodeFromCmd(cmd *cobra.Command, ctx *config.Context) string

StoreCodeFromCmd resolves the effective store code: the --store-code flag if set (the persistent root flag or a per-command override), otherwise the context's configured store code.

func StructuredOutputRequested added in v0.1.4

func StructuredOutputRequested(cmd *cobra.Command) bool

StructuredOutputRequested reports whether the user selected a structured output mode (--json, --yaml, or --template) for this command.

func Truncate added in v0.1.4

func Truncate(s string, max int) string

Truncate shortens s to at most max runes for table display, appending "..." when content is dropped. For max <= 3 there is no room for an ellipsis, so it returns the first max runes.

func ValidateLimit added in v0.1.4

func ValidateLimit(limit int) error

ValidateLimit checks a --limit flag value against the supported page-size range (1 to magento.MaxPageSize).

func WriteOutput

func WriteOutput(cmd *cobra.Command, w io.Writer, data any, fallback func() error) error

Types

type ExitError

type ExitError struct {
	Code int
	Msg  string
}

func (*ExitError) Error

func (e *ExitError) Error() string

type Factory

type Factory struct {
	AppVersion     string
	ExecutableName string

	IOStreams *iostreams.IOStreams

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

	Browser  browser.Browser
	Pager    pager.Manager
	Prompter prompter.Interface
	Spinner  progress.Spinner
	// contains filtered or unexported fields
}

func (*Factory) BrowserOpener

func (f *Factory) BrowserOpener() browser.Browser

func (*Factory) PagerManager

func (f *Factory) PagerManager() pager.Manager

func (*Factory) ProgressSpinner

func (f *Factory) ProgressSpinner() progress.Spinner

func (*Factory) Prompt

func (f *Factory) Prompt() prompter.Interface

func (*Factory) ResolveConfig

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

func (*Factory) Streams

func (f *Factory) Streams() (*iostreams.IOStreams, error)

type OutputSettings

type OutputSettings struct {
	Format   string
	JQ       string
	Template string
}

func ResolveOutputSettings

func ResolveOutputSettings(cmd *cobra.Command) (OutputSettings, error)

Jump to

Keyboard shortcuts

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