clientcmd

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package clientcmd is the CLIENT-side analog of chassis/clicmd: a registry for overlay-supplied `txco` subcommands that run in the CLI process (signing a request to a tenant-scoped admin endpoint, opening a browser) rather than being forwarded to the server's /v1/cli. An overlay self-registers handlers from its init(); the product binary activates them with a blank import. Open core registers none, so on a self-hosted chassis these verbs are unknown and the CLI falls through to its normal unknown-subcommand handling.

The seam is deliberately generic — no billing vocabulary. A handler receives an Env carrying everything it needs from the CLI (a signed tenant client, a browser opener, output writers) so it never reaches into the cli package's unexported signing internals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, h Handler)

Register adds a top-level verb handler (`txco <name> ...`). Called from a backend package's init().

func RegisterAdmin

func RegisterAdmin(sub string, h Handler)

RegisterAdmin adds a handler under the `admin` group (`txco admin <sub> ...`), so an overlay can extend `admin` without open core knowing the subcommand.

Types

type Env

type Env struct {
	Stdout, Stderr io.Writer
	// TenantClient returns a signed admin client scoped to the resolved tenant.
	// It errors when no chassis target is configured (not logged in / no --addr).
	TenantClient func() (*client.Client, error)
	// OpenURL opens a URL in the user's browser (falls back to printing).
	OpenURL func(url string) error
}

Env is the CLI context handed to a client command. The cli package builds it from the global connection flags (--profile/--addr/--tenant/...) before invoking the handler.

type Handler

type Handler func(env Env, args []string) int

Handler runs one client command. args is everything after the verb with the global connection flags already stripped (the command's own flags + positionals). The return value is the process exit code.

func Lookup

func Lookup(name string) (Handler, bool)

Lookup returns the top-level handler for name, if registered.

func LookupAdmin

func LookupAdmin(sub string) (Handler, bool)

LookupAdmin returns the `admin <sub>` handler for sub, if registered.

Jump to

Keyboard shortcuts

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