cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package cli holds the commands of the avero binary, S14. The command in cmd/avero is a thin wrapper, so a test drives the commands with no process.

Index

Constants

View Source
const EnvFile = ".env"

EnvFile is the file that a person writes beside the application. `avero dev` reads it, so the loop needs no export in the shell.

View Source
const ProjectFile = "avero.json"

ProjectFile is the file that states the shape of an application and the entry points of its assets. `avero new` writes it.

Variables

View Source
var Version = "dev"

Version is the version of the binary. The release build sets it.

Functions

func GenerateCheck

func GenerateCheck(dir string) error

GenerateCheck proves that every generated file of the application is current. It runs in this process, so the application needs no dependency on the avero binary. The MCP server calls the same function. See S16.

func Run

func Run(ctx context.Context, s Streams, args []string) int

Run performs one command and returns the exit code of the process.

func Slice

func Slice(dir, name string) (written []string, registered bool, err error)

Slice writes one feature slice, registers it and writes the generated files. The MCP tool scaffold_slice calls it, so an agent and a person write the same files. See the SDD, S16.

Types

type Project

type Project struct {
	// Name is the name of the application.
	Name string `json:"name"`
	// Shape is ssr, spa or api.
	Shape string `json:"shape"`
	// Hypermedia is datastar or htmx. An api holds none.
	Hypermedia string `json:"hypermedia,omitempty"`
	// Assets states the asset pipeline.
	Assets ProjectAssets `json:"assets"`
	// Migrations is the directory that holds the migration files.
	Migrations string `json:"migrations"`
}

Project is the content of avero.json.

func LoadProject

func LoadProject(dir string) (*Project, error)

LoadProject reads avero.json from dir.

An absent file gives the defaults, so a command works in a directory that a person wrote by hand. A file that exists states the whole asset pipeline: a member that it does not name is empty, so a project that names no Tailwind input runs no Tailwind.

func (*Project) Save

func (p *Project) Save(dir string) error

Save writes avero.json into dir.

type ProjectAssets

type ProjectAssets struct {
	// Entries names each entry point, relative to the assets directory.
	Entries []string `json:"entries"`
	// Tier is bundled, node or external.
	Tier string `json:"tier,omitempty"`
	// Command runs the external bundler of tier 2.
	Command []string `json:"command,omitempty"`
	// Tailwind states the stylesheet and the pinned version. An empty input
	// runs no Tailwind.
	Tailwind ProjectTailwind `json:"tailwind"`
}

ProjectAssets states the asset pipeline of one application.

type ProjectTailwind

type ProjectTailwind struct {
	// Input is the stylesheet that Tailwind reads.
	Input string `json:"input,omitempty"`
	// Version is the pinned release of the standalone binary.
	Version string `json:"version,omitempty"`
	// Asset is the name that the manifest records.
	Asset string `json:"asset,omitempty"`
}

ProjectTailwind states the Tailwind build.

type Streams

type Streams struct {
	// Out receives the result of a command.
	Out io.Writer
	// Err receives a fault.
	Err io.Writer
	// In carries the requests of `avero mcp`. A nil value reads the standard
	// input.
	In io.Reader
	// Dir is the working directory. An empty value is the process
	// directory.
	Dir string
}

Streams holds the input and the output of one run.

Jump to

Keyboard shortcuts

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