command

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package command is what the adapter's own commands share: the module they run in, the templates they write from, and how they say what they did.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReportAction

func ReportAction(text string)

func ReportWarning

func ReportWarning(text string)

Not an error: the run succeeded, and this is about something it deliberately did not touch.

func TakeValues

func TakeValues(args []string, flag, takes string) (values, rest []string, err error)

Called before Operands, which would count a flag and its value as operands.

func WriteIfChanged

func WriteIfChanged(path string, body []byte) (bool, error)

For a file that is regenerated rather than scaffolded: one already holding body is not touched, so a run that changes nothing leaves no trace on disk.

Types

type Command

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

func New

func New(name, description string) *Command

func (*Command) Code

func (c *Command) Code() string

func (*Command) Description

func (c *Command) Description() string

func (*Command) Operands

func (c *Command) Operands(args []string, min, max int) error

An extra operand is refused rather than dropped, and so is a flag.

func (*Command) Synopsis

func (c *Command) Synopsis() string

Synopsis is the operands' first line, as a list of commands shows them.

func (*Command) Usage

func (c *Command) Usage() string

func (*Command) WithUsage

func (c *Command) WithUsage(operands string) *Command

One string, so a bad invocation and --help cannot disagree.

type Project

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

Every path a Project takes or reports is relative to the module root, not to the working directory.

func OpenProject

func OpenProject() (*Project, error)

func (*Project) Module

func (p *Project) Module() string

func (*Project) Path

func (p *Project) Path(elem ...string) string

func (*Project) Root

func (p *Project) Root() string

func (*Project) Write

func (p *Project) Write(templates Templates, sources map[string]string, params any) error

Write scaffolds: a target that exists is left alone, and said to be.

type Templates

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

func NewTemplates

func NewTemplates(files embed.FS) Templates

func (Templates) Render

func (t Templates) Render(source string, params any) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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