gen_commands

command
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

gen_commands reads a schema YAML file and generates Cobra command boilerplate for each operation, writing the output to the specified Go file.

Usage: go run scripts/gen_commands/main.go <schema.yaml> <output.go>

The generated file defines NewXxxCommand() which wires all operations as sub-commands under a parent command. Each generated command:

  • Reads path parameters as required --flags
  • Reads query parameters as optional --flags (typed from schema)
  • For POST/PUT/PATCH operations, generates typed --flags from the request body schema
  • Falls back to --body for raw JSON input (advanced)
  • Calls handlers.Dispatch with method, URL template, params, etc.

This script is run in CI whenever the schema changes.

Jump to

Keyboard shortcuts

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