Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 62 Imported by: 0

Documentation

Overview

Package cli implements the oku command tree.

Index

Constants

This section is empty.

Variables

View Source
var ServiceMutations = map[string]bool{
	"orders prepare": true, "positions leverage": true, "positions margin": true,
	"orders submit": true, "orders cancel": true, "orders reconcile": true, "orders abandon": true,
	"send submit": true, "deposit submit": true, "swap submit": true, "send reconcile": true, "swap reconcile": true,
	"bridge submit": true, "bridge reconcile": true, "bridge claim": true, "deposit reconcile": true,
	"swap orders create": true, "swap orders cancel": true, "swap orders watch": true,
}

ServiceMutations are journal/exchange mutations a Service runs only when constructed with AllowMutations. Login, logout, profile, skills and server commands are never reachable through a Service.

View Source
var ServiceReads = map[string]bool{
	"wallet address": true, "wallet balances": true, "wallet fund": true, "deposit address": true,
	"send prepare": true, "send status": true, "deposit prepare": true, "deposit status": true,
	"swap quote": true, "swap prepare": true, "swap status": true,
	"bridge quote": true, "bridge prepare": true, "bridge status": true,
	"version": true, "doctor": true, "auth status": true, "profiles list": true,
	"markets list": true, "markets quote": true, "markets funding": true,
	"account summary": true, "positions list": true, "orders list": true,
	"orders status": true, "orders intents": true, "fills list": true,
	"docs list": true, "docs show": true, "docs search": true, "docs commands": true,
	"swap orders list": true, "pnl": true,
}

ServiceReads are commands a Service runs by default. Prepare commands may create backend orders and journal records, but never sign or broadcast. They do not submit onchain transactions or change user configuration.

Functions

func InputSchema

func InputSchema(path string) (map[string]any, error)

InputSchema returns the draft 2020-12 schema generated from live command flags.

func WriteCommandReference

func WriteCommandReference(w io.Writer) error

WriteCommandReference emits the deterministic command reference from the same urfave command tree that dispatches the executable.

Types

type App

type App struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader
	// StdinIsTTY enables interactive masked prompts. When false, commands
	// never prompt; they fail with a structured error instead.
	StdinIsTTY  bool
	StderrIsTTY bool
	// ReadSecret reads a line from the terminal without echo. It is used only
	// to convert legacy passphrase-protected credentials.
	ReadSecret func(prompt string) ([]byte, error)
	Getenv     func(string) string
	Now        func() time.Time
	// Sleep waits between enrollment polls; overridable in tests.
	Sleep   func(ctx context.Context, d time.Duration) error
	OpenURL func(string) error
	Version string
	// contains filtered or unexported fields
}

App holds process I/O so commands are testable end to end.

func NewApp

func NewApp(version string) *App

NewApp returns an App wired to the real process.

func (*App) Run

func (a *App) Run(args []string) int

Run executes the CLI and returns the process exit code.

type Globals

type Globals struct {
	Profile string
	Network string
	Account string
	Timeout time.Duration
}

Globals mirrors the executable's global options.

type MCPBackend

type MCPBackend struct {
	S      *Service
	Launch Globals
}

MCPBackend adapts Service to the MCP backend interface. Launch holds the globals `oku mcp serve` was started with. When Launch.Profile is set the server is pinned to that profile: tools inherit it and a tool asking for a different profile is refused, so an agent cannot silently switch accounts.

func (MCPBackend) Call

func (b MCPBackend) Call(ctx context.Context, path string, g mcp.Globals, opts map[string]any, args []string) (any, error)

Call implements mcp.Backend.

func (MCPBackend) Commands

func (b MCPBackend) Commands() []mcp.Command

Commands implements mcp.Backend.

type Service

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

Service exposes the command handlers in-process so other front ends (the MCP server) share the exact validation, authentication, signing and journal code paths of the executable instead of shelling out to it. A Service never prompts: it has no terminal, so login, logout and legacy credential conversion fail with a structured error.

func NewService

func NewService(version string, stderr io.Writer, getenv func(string) string) *Service

NewService returns a non-interactive service. Diagnostics go to stderr; nothing is ever written to stdout.

func (*Service) AllowMutations

func (s *Service) AllowMutations(on bool)

AllowMutations enables the ServiceMutations commands.

func (*Service) Call

func (s *Service) Call(ctx context.Context, path string, g Globals, flags map[string]any, args []string) (any, error)

Call runs the command at path (e.g. "orders prepare") with typed flag values and positional args. It returns the same data the --json envelope carries, or an *output.Error.

func (*Service) Commands

func (s *Service) Commands() map[string]string

Commands returns the supported command paths and their summaries.

Jump to

Keyboard shortcuts

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