1package cmd
 2
 3import (
 4	"encoding/json"
 5	"fmt"
 6
 7	"github.com/charmbracelet/crush/internal/config"
 8	"github.com/invopop/jsonschema"
 9	"github.com/spf13/cobra"
10)
11
12var schemaCmd = &cobra.Command{
13	Use:    "schema",
14	Short:  "Generate JSON schema for configuration",
15	Long:   "Generate JSON schema for the crush configuration file",
16	Hidden: true,
17	RunE: func(cmd *cobra.Command, args []string) error {
18		reflector := new(jsonschema.Reflector)
19		bts, err := json.MarshalIndent(reflector.Reflect(&config.Config{}), "", "  ")
20		if err != nil {
21			return fmt.Errorf("failed to marshal schema: %w", err)
22		}
23		fmt.Println(string(bts))
24		return nil
25	},
26}
27
28func init() {
29	rootCmd.AddCommand(schemaCmd)
30}