cli

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestBody added in v0.19.0

func RequestBody(value string) (io.Reader, string, error)

Types

type App

type App struct {
	URL       *url.URL
	ExtraArgs []string

	Cfg config.Config

	AWSSigv4         *aws.Config
	Basic            *core.KeyVal[string]
	Bearer           string
	BuildInfo        bool
	Clobber          bool
	Complete         string
	ConfigPath       string
	ContentType      string
	Data             io.Reader
	Discard          bool
	DryRun           bool
	Edit             bool
	Form             []core.KeyVal[string]
	FromCurl         string
	GRPC             bool
	Help             bool
	InspectTLS       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
	Version          bool
	// contains filtered or unexported fields
}

App represents the full configuration for a fetch invocation.

func Parse

func Parse(args []string) (*App, error)

func (*App) CLI

func (a *App) CLI() *CLI

func (*App) PrintHelp added in v0.4.1

func (a *App) PrintHelp(p *core.Printer)

type Arguments

type Arguments struct {
	Name        string
	Description string
}

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
}

type Flag

type Flag struct {
	Short       string
	Long        string
	Aliases     []string
	Args        string
	Description string
	Default     string
	Values      []core.KeyVal[string]
	HideValues  bool
	IsHidden    bool
	IsSet       func() bool
	OS          []string
	Fn          func(value string) error
}

func (Flag) WithAliases added in v0.20.0

func (f Flag) WithAliases(aliases ...string) Flag

WithAliases adds aliases to the Flag.

func (Flag) WithDefault added in v0.20.0

func (f Flag) WithDefault(def string) Flag

WithDefault sets the default value shown in help.

func (Flag) WithHidden added in v0.20.0

func (f Flag) WithHidden(hidden bool) Flag

WithHidden marks the flag as hidden from help output.

func (Flag) WithHideValues added in v0.20.0

func (f Flag) WithHideValues() Flag

WithHideValues hides the accepted values from help output.

func (Flag) WithOS added in v0.20.0

func (f Flag) WithOS(os []string) Flag

WithOS restricts the flag to specific operating systems.

func (Flag) WithValues added in v0.20.0

func (f Flag) WithValues(values []core.KeyVal[string]) Flag

WithValues sets the accepted values for the Flag.

type MissingEnvVarError added in v0.6.0

type MissingEnvVarError struct {
	EnvVar string
	Flag   string
}

MissingEnvVarError is returned when a required environment variable is not set for a given flag.

func (*MissingEnvVarError) Error added in v0.6.0

func (err *MissingEnvVarError) Error() string

func (*MissingEnvVarError) PrintTo added in v0.6.0

func (err *MissingEnvVarError) PrintTo(p *core.Printer)

Jump to

Keyboard shortcuts

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