cli

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Overview

Package cli implements the `backyard` command line (SPEC §13): the server entry points (serve, gateway, dev), the developer workflow (init, deploy, login, sites, open, pull, token, skill), the MCP server for agents, and `backyard cloudflare setup|domain|access|status` for the Workers edition.

NewRootCommand builds the cobra command tree; every side effect (process execution, browser launch, templates, the embedded skill, the server runtime) goes through an injectable dependency so commands are testable end to end against a fake gateway.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, streams IOStreams, args []string) int

Execute runs the command line args with streams and returns the process exit code. The first SIGINT/SIGTERM cancels the command's context (so servers shut down gracefully and transfers stop cleanly); a second one terminates the process with the default signal behaviour.

func Main

func Main() int

Main is the entry point used by cmd/backyard.

func NewRootCommand

func NewRootCommand(streams IOStreams) *cobra.Command

NewRootCommand builds the `backyard` command tree writing to streams.

Types

type Command

type Command struct {
	Name string
	Args []string
	// Dir is the working directory ("" = current).
	Dir string
	// Env holds extra KEY=VALUE pairs added to the inherited environment.
	Env    []string
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

Command is an external process invocation.

func (Command) Argv

func (c Command) Argv() []string

Argv returns the full argument vector.

func (Command) String

func (c Command) String() string

String renders the command as a shell-like line (for display only).

type ExitError

type ExitError struct {
	Code int
	Err  error
}

ExitError carries a specific process exit code.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

type IOStreams

type IOStreams struct {
	In     io.Reader
	Out    io.Writer
	ErrOut io.Writer
}

IOStreams are the standard streams of a command invocation.

func StdStreams

func StdStreams() IOStreams

StdStreams returns the process's stdin, stdout and stderr.

type Runner

type Runner interface {
	Run(ctx context.Context, c Command) error
}

Runner executes external commands.

Directories

Path Synopsis
Package clitest provides an in-memory fake of a Backyard server's client surface (the deploy gateway protocol of SPEC §7, the CLI login handoff of §8.3 and POST /__backyard/api/tokens) for testing the CLI and the MCP server without running the real server.
Package clitest provides an in-memory fake of a Backyard server's client surface (the deploy gateway protocol of SPEC §7, the CLI login handoff of §8.3 and POST /__backyard/api/tokens) for testing the CLI and the MCP server without running the real server.
Package scaffold writes the files of a new Backyard project (`backyard init` and the MCP tool backyard_init) and provides SafeJoin, the path guard used whenever the CLI writes files whose names come from elsewhere (templates, `backyard pull`).
Package scaffold writes the files of a new Backyard project (`backyard init` and the MCP tool backyard_init) and provides SafeJoin, the path guard used whenever the CLI writes files whose names come from elsewhere (templates, `backyard pull`).

Jump to

Keyboard shortcuts

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