inspect

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InspectCmd = &cobra.Command{
	Use:   "inspect",
	Short: "Inspect Manglekit objects",
	Args:  cobra.NoArgs,
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}
View Source
var StructCmd = &cobra.Command{
	Use:   "struct",
	Short: "Inspect a struct and see the generated Mangle facts.",
	Long:  `Parses a JSON string or file representing a struct and uses the core reflection engine to generate Mangle Datalog facts. This helps users understand how Manglekit perceives their data structures.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		var jsonData []byte
		var err error

		if _, err := os.Stat(jsonFlag); err == nil {
			jsonData, err = os.ReadFile(jsonFlag)
			if err != nil {
				return fmt.Errorf("failed to read JSON file: %w", err)
			}
		} else {
			jsonData = []byte(jsonFlag)
		}

		var data map[string]any
		if err := json.Unmarshal(jsonData, &data); err != nil {
			return fmt.Errorf("failed to unmarshal JSON: %w", err)
		}

		facts, err := engine.ToFacts("request", data)
		if err != nil {
			return fmt.Errorf("failed to generate facts: %w", err)
		}

		for _, fact := range facts {
			fmt.Println(fact)
		}

		return nil
	},
}

Functions

func AddCommands

func AddCommands(rootCmd *cobra.Command)

Types

This section is empty.

Jump to

Keyboard shortcuts

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