diff --git a/cmd/cycles.go b/cmd/cycles.go index 718f36f..f0ae2da 100644 --- a/cmd/cycles.go +++ b/cmd/cycles.go @@ -29,6 +29,7 @@ var jsonOutputCycles bool var summaryOutputCycles bool var maxCycleLength int var cyclesTopN int +var cyclesVerbose bool var cyclesSplitTestOnly bool // cyclesFinder implements Johnson's algorithm for finding all elementary cycles @@ -120,6 +121,13 @@ var cyclesCmd = &cobra.Command{ if !jsonOutputCycles && summaryOutputCycles { printCycleSummary(summary) + if cyclesVerbose { + fmt.Println() + fmt.Println("All cycles in dependencies are: ") + for _, c := range cycles { + printChain(c) + } + } } if jsonOutputCycles { @@ -475,6 +483,7 @@ func init() { cyclesCmd.Flags().BoolVar(&cyclesSplitTestOnly, "split-test-only", false, "Split cycles into test-only and non-test sections (uses go mod why -m)") cyclesCmd.Flags().StringSliceVar(&excludeModules, "exclude-modules", []string{}, "Exclude module path patterns (repeatable, supports * wildcard)") cyclesCmd.Flags().StringSliceVarP(&mainModules, "mainModules", "m", []string{}, "Enter modules whose dependencies should be considered direct dependencies; defaults to the first module encountered in `go mod graph` output") + cyclesCmd.Flags().BoolVarP(&cyclesVerbose, "verbose", "v", false, "Include raw cycles with summary output") } func splitCyclesByTestStatus(cycles []Chain, testOnlySet map[string]bool) ([]Chain, []Chain) { diff --git a/cmd/graph.go b/cmd/graph.go index 9f2fede..96c6fcb 100644 --- a/cmd/graph.go +++ b/cmd/graph.go @@ -34,6 +34,7 @@ var graphJSONOutput bool var graphOutputPath string var graphTopMode string var graphTopN int +var graphVerbose bool var graphSplitTestOnly bool type graphNode struct { @@ -177,6 +178,14 @@ var graphCmd = &cobra.Command{ fmt.Print(fileContents) return nil } + if graphVerbose { + fmt.Println("Main modules:") + printDeps(overview.MainModules) + fmt.Println("Direct dependencies:") + printDeps(overview.DirectDepList) + fmt.Println("Transitive dependencies:") + printDeps(overview.TransDepList) + } fileContentsByte := []byte(fileContents) err := os.WriteFile(graphOutputPath, fileContentsByte, 0644) @@ -464,6 +473,7 @@ func init() { graphCmd.Flags().BoolVar(&graphSplitTestOnly, "split-test-only", false, "Split graph into test-only and non-test sections (uses go mod why -m)") graphCmd.Flags().StringSliceVar(&excludeModules, "exclude-modules", []string{}, "Exclude module path patterns (repeatable, supports * wildcard)") graphCmd.Flags().StringVar(&graphOutputPath, "output", "graph.dot", "Path to DOT output file when not using --dot or --json") + graphCmd.Flags().BoolVarP(&graphVerbose, "verbose", "v", false, "Include dependency lists in text output") graphCmd.Flags().StringSliceVarP(&mainModules, "mainModules", "m", []string{}, "Specify main modules") } diff --git a/cmd/list.go b/cmd/list.go index 3a05f12..8c32247 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -26,6 +26,7 @@ import ( var listSplitTestOnly bool var listJSONOutput bool +var listVerbose bool // analyzeDepsCmd represents the analyzeDeps command var listCmd = &cobra.Command{ @@ -55,6 +56,11 @@ var listCmd = &cobra.Command{ testOnly := filterDepsByTestStatus(allDeps, testOnlySet, true) sort.Strings(nonTest) sort.Strings(testOnly) + if listVerbose { + fmt.Printf("All dependencies (%d):\n", len(allDeps)) + printDeps(allDeps) + fmt.Println() + } if listJSONOutput { outputObj := struct { All []string `json:"allDependencies"` @@ -116,4 +122,5 @@ func init() { listCmd.Flags().StringSliceVar(&excludeModules, "exclude-modules", []string{}, "Exclude module path patterns (repeatable, supports * wildcard)") listCmd.Flags().BoolVarP(&listJSONOutput, "json", "j", false, "Get the output in JSON format") listCmd.Flags().BoolVar(&listSplitTestOnly, "split-test-only", false, "Split list into test-only and non-test sections (uses go mod why -m)") + listCmd.Flags().BoolVarP(&listVerbose, "verbose", "v", false, "Include full dependency list alongside split output") }