{"modulePath":"github.com/osapi-io/osapi","version":"v0.3.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package command\n\nPackage 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.\n\n## Functions\n\n```go\nfunc Build(\n\tg *endpoint.Group,\n\tm *endpoint.Method,\n\tin any,\n) (string, []byte, string, error)\n```\nBuild 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.\n\n```go\nfunc Run[In any](\n\tcmd *cobra.Command,\n\tg *endpoint.Group,\n\tmethod string,\n\tin In,\n)\n```\nRun 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.\n\n```go\nfunc Use(\n\tc func() Caller,\n)\n```\nUse sets what Run sends each request through: a function that returns the SDK client, so the client is made only when a command runs.\n\n## Types\n\n```go\ntype Caller interface {\n\tSend(\n\t\tctx context.Context,\n\t\tmethod string,\n\t\tpath string,\n\t\tcontentType string,\n\t\tbody []byte,\n\t) (*client.Response[json.RawMessage], error)\n}\n```\nCaller sends one request to the API. The SDK client satisfies it.\n\n","path":"github.com/osapi-io/osapi/internal/controller/endpoint/command","name":"command","synopsis":"Package command is the endpoint layer's runner of the generated CLI commands of the endpoint groups.","isRedistributable":true}
