# marmot generate (/docs/commands/generate)

<!-- Generated by scripts/gen.mjs from `marmot generate --help` and scripts/commands.mjs. Do not edit by hand. -->

Run the //go:generate directives of the named packages like go generate, and cache what each one writes, keyed by the directive, its environment, the generator binary and the package's other files. A directive whose inputs did not change has its outputs restored instead of running again. -n lists directives and whether they are cached; -force runs everything.

```text title="Usage"
marmot generate [packages] [flags]
```

## Examples [#examples]

```sh
marmot generate ./...
marmot generate -n ./...
marmot generate -run stringer .
```

`marmot generate ./...` runs `//go:generate` directives like `go generate`, and remembers what
each one wrote, keyed by the directive, its environment, the generator binary and the
package's other files. When none of those changed, the outputs are restored instead of running
the generator. `-n` lists directives and whether they are cached; `-force` runs everything.

`-json` writes one `generate` object per directive (`command`, `cached`, `outputs`) and a
`result`.

## Flags [#flags]

Flags take one dash or two: `-release` and `--release` are the same.

| Flag | Meaning |
| --- | --- |
| `-color string` | color in human output: auto, always or never (NO_COLOR turns auto off) (default "auto") |
| `-force` | run every directive, ignoring the cache |
| `-json` | machine readable output: JSON Lines on stderr (also $MARMOT_OUTPUT=json, and the default under coding agents) |
| `-n` | print the directives and whether they are cached; run nothing |
| `-run string` | only directives whose text contains this |
| `-v` | print each directive as it runs |

## Full help [#full-help]

```text title="marmot generate --help"
Run the //go:generate directives of the named packages like go generate, and cache what each one writes, keyed by the directive, its environment, the generator binary and the package's other files. A directive whose inputs did not change has its outputs restored instead of running again. -n lists directives and whether they are cached; -force runs everything.

Usage:
  marmot generate [packages] [flags]

Examples:
marmot generate ./...
marmot generate -n ./...
marmot generate -run stringer .

Flags:
      --color string   color in human output: auto, always or never (NO_COLOR turns auto off) (default "auto")
      --force          run every directive, ignoring the cache
  -h, --help           help for generate
      --json           machine readable output: JSON Lines on stderr (also $MARMOT_OUTPUT=json, and the default under coding agents)
      --n              print the directives and whether they are cached; run nothing
      --run string     only directives whose text contains this
      --v              print each directive as it runs
```