Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx9FNLG2CqeBbVGGd9bFsP
26 lines
526 B
Go
26 lines
526 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/v10networks/nmon/internal/app"
|
|
)
|
|
|
|
func init() {
|
|
register("openapi", "print the generated OpenAPI 3.1 document (nmon openapi > openapi.json)", openapiCmd)
|
|
}
|
|
|
|
func openapiCmd(_ context.Context, args []string) error {
|
|
if len(args) > 0 {
|
|
return fmt.Errorf("openapi takes no arguments, got %q", args[0])
|
|
}
|
|
spec, err := app.OpenAPISpec()
|
|
if err != nil {
|
|
return fmt.Errorf("generate spec: %w", err)
|
|
}
|
|
_, err = fmt.Fprintf(os.Stdout, "%s\n", spec)
|
|
return err
|
|
}
|