From 6d0fd2de2fbe920db7d37b9f7783b7424ed67f58 Mon Sep 17 00:00:00 2001 From: "Dr. Q and Company" <213266729+drQedwards@users.noreply.github.com> Date: Mon, 13 Jul 2026 13:31:03 -0400 Subject: [PATCH] Create supergraph.go --- cmd/supergraph.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cmd/supergraph.go diff --git a/cmd/supergraph.go b/cmd/supergraph.go new file mode 100644 index 0000000..006d82f --- /dev/null +++ b/cmd/supergraph.go @@ -0,0 +1,44 @@ +package cmd + +import ( + "github.com/spf13/cobra" + + "github.com/supermodeltools/cli/internal/config" + "github.com/supermodeltools/cli/internal/graph" +) + +func init() { + var opts graph.Options + + c := &cobra.Command{ + Use: "graph [path]", + Short: "Display the repository graph", + Long: `Fetches or loads the cached graph and renders it. + +Output formats: + human — aligned table of nodes (default) + json — full graph as JSON + dot — Graphviz DOT for use with dot/graphviz`, + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + cfg, err := config.Load() + if err != nil { + return err + } + if err := cfg.RequireAPIKey(); err != nil { + return err + } + dir := "." + if len(args) > 0 { + dir = args[0] + } + return graph.Run(cmd.Context(), cfg, dir, opts) + }, + } + + c.Flags().BoolVar(&opts.Force, "force", false, "re-analyze even if a cached result exists") + c.Flags().StringVarP(&opts.Output, "output", "o", "human", "output format: human|json|dot") + c.Flags().StringVar(&opts.Filter, "label", "", "filter nodes by label (File, Function, Class, …)") + + rootCmd.AddCommand(c) +}