cmd

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request is an abstraction over the actual command with flags. This abstraction is useful because it allows us to create cmd applications in same way we would create a HTTP server application. Kite's http.Request is another such abstraction.

func NewRequest

func NewRequest(args []string) *Request

NewRequest creates a Request from a list of arguments. This way we can simulate running a command without actually doing it. It makes the code more testable this way.

func (*Request) Arg added in v0.1.1

func (r *Request) Arg(index int) string

Arg returns the positional argument at the given index (0-based, after command words). Returns empty string if index is out of range.

func (*Request) Args added in v0.1.1

func (r *Request) Args() []string

Args returns all positional arguments.

func (*Request) Bind

func (r *Request) Bind(i any) error

func (*Request) Context

func (*Request) Context() context.Context

func (*Request) HostName

func (*Request) HostName() (hostname string)

func (*Request) Param

func (r *Request) Param(key string) string

Param returns the value of the parameter for key.

func (*Request) Params

func (r *Request) Params(key string) []string

Params retrieves all values for a given query parameter key, including comma-separated values.

func (*Request) PathParam

func (r *Request) PathParam(key string) string

PathParam returns the value of the parameter for key. This is equivalent to Param.

type Responder

type Responder struct{}

func (*Responder) Respond

func (*Responder) Respond(data any, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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