Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions cmd/supergraph.go
Original file line number Diff line number Diff line change
@@ -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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove duplicate graph command registration

cmd/graph.go:10-43 already registers the same Use: "graph [path]" command, so this second init adds a duplicate child to rootCmd. I checked Cobra v1.10.2: AddCommand appends each child to c.commands, and the default help iterates .Commands, so users will see duplicate graph entries in help/completions/docs rather than getting a distinct supergraph command. Remove this duplicate or give it a distinct command name.

Useful? React with 👍 / 👎.

}
Loading