cli

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package cli is the momo command line tool as a library. The momo binary (cmd/momo) is a thin caller of Main; a team that writes its own gen.Plugin builds a binary with the same behavior and its plugins selectable from momo.yaml:

package main

import "github.com/azrtydxb/momo/cli"

func main() { cli.Main(myPlugin{}) }

Build it with go build and run it where you would run momo: the commands, flags, exit codes and diagnostics are the ones of `momo generate`, and a plugin passed to Main is enabled by naming it in the plugins section of momo.yaml. A plugin that is not passed to Main cannot be enabled: naming it is a configuration error (exit 2).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(plugins ...gen.Plugin)

Main is the entry point of a custom momo binary: put it in a main function and the binary behaves as `momo` does (commands, flags, exit codes, diagnostics) with the given generator plugins selectable by name from the plugins section of momo.yaml. It runs Run with the process arguments, standard output and standard error, then exits with the code Run returns. Main does not return, so write nothing after it.

func Run

func Run(args []string, stdout, stderr io.Writer, plugins ...gen.Plugin) int

Run executes the momo CLI with args (without the program name), writes its output to stdout and its diagnostics to stderr, and returns the process exit code: 0 for success or current generated code, 1 for stale generated files or generator diagnostics, 2 for a usage, configuration or infrastructure error, and 3 for a database, lock or execution error (momo migrate). The plugins are the generator plugins this run offers; momo.yaml enables them by name, and naming one that is not passed here is a configuration error. Run is the testable form of Main: a custom binary calls Main, a test calls Run with its own writers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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