Documentation
¶
Index ¶
- Variables
- func ClientFromCmd(f *Factory, cmd *cobra.Command) (*iostreams.IOStreams, *magento.Client, error)
- func FlagValue(cmd *cobra.Command, name string) string
- func HostKeyFromURL(baseURL string) (string, error)
- func NewHTTPClient(host *config.Host, storeCode string) (*httpx.Client, error)
- func NewMagentoClient(host *config.Host, storeCode string) (*magento.Client, error)
- func NormalizeBaseURL(raw string) (string, error)
- func NotImplemented(cmd *cobra.Command) error
- func ResolveContext(f *Factory, cmd *cobra.Command, override string) (string, *config.Context, *config.Host, error)
- func ResolveHost(f *Factory, contextOverride, hostOverride string) (string, *config.Host, error)
- func StoreCodeFromCmd(cmd *cobra.Command, ctx *config.Context) string
- func StructuredOutputRequested(cmd *cobra.Command) bool
- func Truncate(s string, max int) string
- func ValidateLimit(limit int) error
- func WriteOutput(cmd *cobra.Command, w io.Writer, data any, fallback func() error) error
- type ExitError
- type Factory
- func (f *Factory) BrowserOpener() browser.Browser
- func (f *Factory) PagerManager() pager.Manager
- func (f *Factory) ProgressSpinner() progress.Spinner
- func (f *Factory) Prompt() prompter.Interface
- func (f *Factory) ResolveConfig() (*config.Config, error)
- func (f *Factory) Streams() (*iostreams.IOStreams, error)
- type OutputSettings
Constants ¶
This section is empty.
Variables ¶
var ( ErrSilent = errors.New("silent") ErrPending = errors.New("pending") )
Functions ¶
func ClientFromCmd ¶ added in v0.1.4
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 HostKeyFromURL ¶
func NewHTTPClient ¶
NewHTTPClient constructs a raw HTTP client for the configured host.
func NewMagentoClient ¶
NewMagentoClient constructs a Magento API client from the resolved context.
func NormalizeBaseURL ¶
func NotImplemented ¶
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 ¶
ResolveHost locates a host configuration using optional context or host overrides.
func StoreCodeFromCmd ¶ added in v0.1.4
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
StructuredOutputRequested reports whether the user selected a structured output mode (--json, --yaml, or --template) for this command.
func Truncate ¶ added in v0.1.4
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
ValidateLimit checks a --limit flag value against the supported page-size range (1 to magento.MaxPageSize).
Types ¶
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 (*Factory) PagerManager ¶
func (*Factory) ProgressSpinner ¶
type OutputSettings ¶
func ResolveOutputSettings ¶
func ResolveOutputSettings(cmd *cobra.Command) (OutputSettings, error)