command

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package command is the endpoint layer's runner of the generated CLI commands of the endpoint groups. Each group's gen/cli.go makes one cobra command for each method and registers it with the command layer, internal/cli/command. Run builds the method's request from its typed input, sends it through the SDK client that Use set, and gives the answer to the command layer, which prints it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(
	g *endpoint.Group,
	m *endpoint.Method,
	in any,
) (string, []byte, string, error)

Build is the request that sends in to method m of g: the key in the path, the query fields in the query, and the other fields as the JSON body.

func Run

func Run[In any](
	cmd *cobra.Command,
	g *endpoint.Group,
	method string,
	in In,
)

Run sends method m of g with in, and gives the answer to the command layer to print. The answer decodes into the type of the method's renderer, so the generated command does not name its output type.

func Use

func Use(
	c func() Caller,
)

Use sets what Run sends each request through: a function that returns the SDK client, so the client is made only when a command runs.

Types

type Caller

type Caller interface {
	Send(
		ctx context.Context,
		method string,
		path string,
		contentType string,
		body []byte,
	) (*client.Response[json.RawMessage], error)
}

Caller sends one request to the API. The SDK client satisfies it.

Jump to

Keyboard shortcuts

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