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.
Click to show internal directories.
Click to hide internal directories.