Documentation
¶
Index ¶
- func RequestBody(value string) (io.Reader, string, error)
- type App
- func (a *App) CLI() *CLI
- func (a *App) HasGRPCDiscovery() bool
- func (a *App) HasGRPCMode() bool
- func (a *App) HasProtoSchema() bool
- func (a *App) OptionProvenance(name string) OptionProvenance
- func (a *App) OptionWasExplicit(name string) bool
- func (a *App) PrintHelp(p *core.Printer)
- func (a *App) RecordConfigKeys(keys []string, source OptionSource)
- func (a *App) RecordConfigSource(c *config.Config, source OptionSource)
- func (a *App) RecordEnvironment(name string)
- type Arguments
- type CLI
- type Flag
- func (f Flag) WithAliasValues(values map[string]string) Flag
- func (f Flag) WithAliases(aliases ...string) Flag
- func (f Flag) WithDefault(def string) Flag
- func (f Flag) WithHidden(hidden bool) Flag
- func (f Flag) WithHideValues() Flag
- func (f Flag) WithOS(os []string) Flag
- func (f Flag) WithValues(values []core.KeyVal[string]) Flag
- type OptionMode
- type OptionProvenance
- type OptionRegistry
- func (r *OptionRegistry) Flags() []Flag
- func (r *OptionRegistry) Ignored(mode OptionMode, explicit func(string) bool) []string
- func (r *OptionRegistry) LongFlags() map[string]Flag
- func (r *OptionRegistry) Lookup(name string) (Flag, bool)
- func (r *OptionRegistry) ShortFlags() map[string]Flag
- func (r *OptionRegistry) String() string
- func (r *OptionRegistry) Unsupported(mode OptionMode) (string, bool)
- func (r *OptionRegistry) Validate() error
- func (r *OptionRegistry) ValidateScheme(scheme string) error
- type OptionSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
URL *url.URL
ExtraArgs []string
SchemelessURL bool
Cfg config.Config
AWSSigv4 *aws.Config
Basic *core.KeyVal[string]
Bearer string
Digest *core.KeyVal[string]
BuildInfo bool
Clobber bool
Complete string
ConfigPath string
ContentType string
Data io.Reader
Discard bool
DryRun bool
Edit bool
Article bool
Form []core.KeyVal[string]
FromCurl string
GRPC bool
GRPCDescribe string
GRPCList bool
HAR string
Help bool
InspectDNS bool
InspectTLS bool
Skill bool
InstallSkill string
UninstallSkill string
Scope string
Force bool
SortHeaders bool
WS bool // set when URL scheme is ws:// or wss://
Method string
Multipart []core.KeyVal[string]
Output string
ProtoDesc string
ProtoFiles []string
ProtoImports []string
Range []string
RemoteHeaderName bool
RemoteName bool
UnixSocket string
Update bool
CheckUpdate bool
Version bool
WSInteractive core.WSInteractiveMode
WSMessageMode core.WSMessageMode
// contains filtered or unexported fields
}
App represents the full configuration for a fetch invocation.
func (*App) HasGRPCDiscovery ¶ added in v0.21.0
func (*App) HasGRPCMode ¶ added in v0.21.0
func (*App) HasProtoSchema ¶ added in v0.21.0
func (*App) OptionProvenance ¶ added in v0.28.0
func (a *App) OptionProvenance(name string) OptionProvenance
OptionProvenance returns the sources that contributed to a canonical option in this invocation. A flag's declared default is reported separately by the registry and is not stored as mutable App state.
func (*App) OptionWasExplicit ¶ added in v0.28.0
OptionWasExplicit reports whether the user supplied an option directly or through curl import. Config defaults deliberately do not count.
func (*App) RecordConfigKeys ¶ added in v0.28.0
func (a *App) RecordConfigKeys(keys []string, source OptionSource)
RecordConfigKeys records only the fields that won a particular merge. This avoids reporting lower-precedence scalar settings as if they contributed.
func (*App) RecordConfigSource ¶ added in v0.28.0
func (a *App) RecordConfigSource(c *config.Config, source OptionSource)
RecordConfigSource records populated config fields after they have been merged. Calling this once per scope preserves global versus host provenance without making Config itself stateful.
func (*App) RecordEnvironment ¶ added in v0.28.0
RecordEnvironment records an environment-derived option for integrations that select environment-backed defaults outside the INI parser.
type CLI ¶
type CLI struct {
Description string
ArgFn func(s string) error
Args []Arguments
Flags []Flag
ExclusiveFlags [][]string
RequiredFlags []core.KeyVal[[]string]
// SchemeExclusiveFlags maps URL schemes (e.g. "ws", "wss") to flags
// that cannot be used with that scheme.
SchemeExclusiveFlags map[string][]string
// FromCurlExclusiveFlags lists flags that cannot be used alongside
// --from-curl.
FromCurlExclusiveFlags []string
// OnOptionSet receives the canonical option name after a successful
// explicit CLI parse. It is used to preserve source provenance.
OnOptionSet func(canonical string)
// contains filtered or unexported fields
}
func (*CLI) Options ¶ added in v0.28.0
func (cli *CLI) Options() *OptionRegistry
Options returns the registry for this CLI definition. The registry is cached so all consumers of one definition see the same enriched metadata.
type Flag ¶
type Flag struct {
Short string
Long string
Aliases []string
AliasValues map[string]string
Args string
OptionalArg bool
Description string
Default string
Values []core.KeyVal[string]
HideValues bool
IsHidden bool
IsSet func() bool
OS []string
Fn func(value string) error
// Registry metadata. These fields keep the option contract next to the
// parser definition so validation, help, completion, and diagnostics share
// the same source of truth.
ConfigKey string
Repeatable bool
Schemes []string
Modes []OptionMode
Conflicts []string
Requires []string
IgnoredIn []OptionMode
IgnoreLabel string
FromCurl bool
UnsupportedIn []OptionMode
}
func (Flag) WithAliasValues ¶ added in v0.28.0
WithAliasValues gives aliases that normally take an argument a fixed value. It is used for compatibility shorthands such as --http2, which is exactly equivalent to --http 2 but has no separate argument.
func (Flag) WithAliases ¶ added in v0.20.0
WithAliases adds aliases to the Flag.
func (Flag) WithDefault ¶ added in v0.20.0
WithDefault sets the default value shown in help.
func (Flag) WithHidden ¶ added in v0.20.0
WithHidden marks the flag as hidden from help output.
func (Flag) WithHideValues ¶ added in v0.20.0
WithHideValues hides the accepted values from help output.
type OptionMode ¶ added in v0.28.0
type OptionMode string
OptionMode is a user-visible command or request mode understood by the option registry.
const ( ModeMetadata OptionMode = "metadata" ModeHTTP OptionMode = "http" ModeGRPC OptionMode = "grpc" ModeGRPCDiscovery OptionMode = "grpc-discovery" ModeWebSocket OptionMode = "websocket" ModeDNSInspection OptionMode = "dns-inspection" ModeTLSInspection OptionMode = "tls-inspection" ModeUpdate OptionMode = "update" ModeSkill OptionMode = "skill" )
type OptionProvenance ¶ added in v0.28.0
type OptionProvenance struct {
Sources []OptionSource
}
OptionProvenance records every source that contributed a value to an option. Multiple sources may be present after config merging.
func (OptionProvenance) Has ¶ added in v0.28.0
func (p OptionProvenance) Has(source OptionSource) bool
type OptionRegistry ¶ added in v0.28.0
type OptionRegistry struct {
// contains filtered or unexported fields
}
OptionRegistry is the single index of the public option surface. Aliases resolve to the canonical long name while retaining the original Flag for parsing and completion.
func (*OptionRegistry) Flags ¶ added in v0.28.0
func (r *OptionRegistry) Flags() []Flag
Flags returns the registry-enriched flags in their declared order.
func (*OptionRegistry) Ignored ¶ added in v0.28.0
func (r *OptionRegistry) Ignored(mode OptionMode, explicit func(string) bool) []string
Ignored returns canonical option labels for a mode, filtered to options explicitly supplied by the user. Config-only values are intentionally not returned.
func (*OptionRegistry) LongFlags ¶ added in v0.28.0
func (r *OptionRegistry) LongFlags() map[string]Flag
func (*OptionRegistry) Lookup ¶ added in v0.28.0
func (r *OptionRegistry) Lookup(name string) (Flag, bool)
func (*OptionRegistry) ShortFlags ¶ added in v0.28.0
func (r *OptionRegistry) ShortFlags() map[string]Flag
func (*OptionRegistry) String ¶ added in v0.28.0
func (r *OptionRegistry) String() string
func (*OptionRegistry) Unsupported ¶ added in v0.28.0
func (r *OptionRegistry) Unsupported(mode OptionMode) (string, bool)
func (*OptionRegistry) Validate ¶ added in v0.28.0
func (r *OptionRegistry) Validate() error
Validate checks registry-declared conflicts and requirements using the canonical names even when the user supplied an alias.
func (*OptionRegistry) ValidateScheme ¶ added in v0.28.0
func (r *OptionRegistry) ValidateScheme(scheme string) error
type OptionSource ¶ added in v0.28.0
type OptionSource uint8
OptionSource identifies where an option value came from. Sources are kept on App rather than Config because a Config can be merged from several scopes before a request is executed.
const ( SourceDefault OptionSource = iota SourceGlobalConfig SourceHostConfig SourceEnvironment SourceCurl SourceCLI )