Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions cmd/cycles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions cmd/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
}

Expand Down
7 changes: 7 additions & 0 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

var listSplitTestOnly bool
var listJSONOutput bool
var listVerbose bool

// analyzeDepsCmd represents the analyzeDeps command
var listCmd = &cobra.Command{
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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")
}
Loading