❯ rotini --documentation█

zz_rotini.go

go generate ./... turns your spec into one Go file, internal/cmd/<name>/zz_rotini.go. It is rewritten on every run, so you never edit it — and you rarely need to read it. This page explains what is in it, so the step from spec to code is not a mystery.

From spec to code

For a spec with a todo command and an add sub-command, the file holds:

In the specIn zz_rotini.go
each command’s flagsa struct — TodoAddFlags { Priority string; Tag []string }
each command’s argumentsa struct — TodoAddArguments { Title string }
its env and config inputs, when it declares anyTodoAddEnv and TodoAddConfig structs
the command and its parentsTodoAddInputs, the type your handler passes to rotini.Collect
the command treea rotini.Definition the runtime parses against
each commanda method wiring it to your handler type (todoAddHandlers)
configuration files and env prefixBindMeta, which tells the runtime where values come from
the help featureHelp(path...), the rendered help pages

It ends with the one thing you do use: Program, built by NewProgram, which main.go runs.

zz_rotini.go (abridged)
// Code generated by rotini; DO NOT EDIT.
package todo

type TodoAddFlags struct {
	Priority string   `rotini:"priority"`
	Tag      []string `rotini:"tag"`
}

type TodoAddArguments struct {
	Title string `rotini:"title"`
}

type TodoAddInputs struct {
	Todo    TodoCommandInputs
	TodoAdd TodoAddCommandInputs
}

func NewProgram(handlers ProgramHandlers) *rotini.Program {
	return rotini.NewProgram(definition, handlers).
		WithBindMeta(BindMeta).
		WithHelp(Help)
}

var Program = NewProgram(&handlers{})

What stays yours

  • The handler files — one per command, created the first time a command appears and never overwritten. If you remove a command from the spec, its handler file is removed on the next go generate (generate prints what it removed), edits and all; delete the file’s var _ rotini.Handlers line or list it under the conf’s keep: to hold on to it.
  • main.go — created once, never touched again.

Names

Generated names follow Go’s conventions: api-group becomes APIGroup, base-url becomes BaseURL. A command port-forward gets the handler file todo_port_forward.go.