extension

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package extension is where a command is written in code.

The contract-driven path turns every operation into a usable command, but it can only express "one operation, one command". Some things are not that shape:

  • `instance start` is `act-on-instance` with one body field fixed
  • `instance launch --wait` is a call followed by polling
  • `login` and `project use` correspond to no operation at all

These live here. They share the kernel with generated commands — same HTTP client, same printer, same config — so --output, --project and token renewal behave identically. A hand-written command should not feel like a different program.

Overriding

When an extension's Path collides with a generated command, the extension wins. That is the point: it is how a command gets improved. The operation it displaces is still reachable as `leaflow <service> op <operationId>`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(commands ...Command)

Types

type Command

type Command struct {
	// Service is the service to hang this under, e.g. "compute". Empty means
	// top level, as for `leaflow login`.
	Service string

	// Path is the command path, so ["instance", "start"] becomes
	// `leaflow compute instance start`. Missing intermediate levels are created.
	Path []string

	// Build constructs the command. Everything in Context is usable by the time
	// it is called.
	Build func(*Context) *cobra.Command
}

func All

func All() []Command

type Context

type Context struct {
	Config  *config.Config
	Tokens  *auth.Manager
	Client  *transport.Client
	Printer *output.Printer
	Specs   *spec.Set
}

Context is what the kernel hands to an extension: capabilities, not raw material. Client already knows which token to attach and how to retry; Printer already knows the requested format.

Jump to

Keyboard shortcuts

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