-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for recursive dep graph #137
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import ( | |
"sort" | ||
"strings" | ||
|
||
"github.com/logrusorgru/aurora" | ||
"github.com/ramantehlan/GoCheckDeb/pkg/gocheckdeb" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we need to get github.com/ramantehlan/GoCheckDeb packaged for Debian first. 🤔 |
||
"golang.org/x/tools/go/vcs" | ||
"golang.org/x/tools/refactor/importgraph" | ||
) | ||
|
@@ -173,8 +175,44 @@ func estimate(importpath string) error { | |
return nil | ||
} | ||
|
||
func recursiveEstimate(importpath string, formatType string) error { | ||
log.Print(aurora.Bold(aurora.Green("[DebGoGraph Starting]"))) | ||
|
||
debFilter := true | ||
displayAll := true | ||
|
||
fmt.Printf("\nGolang package: %s\n", aurora.Bold(importpath)) | ||
fmt.Printf("Output type: %s\n", aurora.Bold(formatType)) | ||
fmt.Printf("Deb filter: %v\n", aurora.Bold(debFilter)) | ||
fmt.Printf("Display all deb (false for only main package): %v\n\n", aurora.Bold(displayAll)) | ||
|
||
fmt.Printf("Fetching dependencies of %s | It may take a while.\n\n", aurora.Bold(aurora.BrightBlue(importpath))) | ||
|
||
// List | Graph | Tree | ||
m, err := gocheckdeb.GetDep(importpath, "imports", formatType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of using many third-party libraries. Especially this library has some overlap functions with dh-make-golang. |
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
m2, err := gocheckdeb.GetDep(importpath, "test", formatType) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
// DepMaps | DebFilder - display deb unpacked | displayAll - Display all unpacked or just head | inc start | ||
fmt.Println(aurora.Bold(aurora.BrightBlue("--Project Dependencies--"))) | ||
gocheckdeb.PrintDep(m, debFilter, displayAll, 0) | ||
fmt.Println(aurora.Bold(aurora.BrightBlue("--Test Dependencies--"))) | ||
gocheckdeb.PrintDep(m2, debFilter, displayAll, 0) | ||
|
||
fmt.Println("") | ||
log.Print(aurora.Bold(aurora.Green("[DebGoGraph Ending]"))) | ||
|
||
return nil | ||
} | ||
|
||
func execEstimate(args []string) { | ||
fs := flag.NewFlagSet("estimate", flag.ExitOnError) | ||
recursiveFlag := fs.Bool("r", false, "(Bool) Recursive output") | ||
formatFlag := fs.String("format", "graph", "('graph', 'map', 'list') Format for the flag") | ||
|
||
fs.Usage = func() { | ||
fmt.Fprintf(os.Stderr, "Usage: %s estimate <go-package-importpath>\n", os.Args[0]) | ||
|
@@ -188,14 +226,18 @@ func execEstimate(args []string) { | |
log.Fatal(err) | ||
} | ||
|
||
if fs.NArg() != 1 { | ||
if fs.NArg() < 1 { | ||
fs.Usage() | ||
os.Exit(1) | ||
} | ||
|
||
// TODO: support the -git_revision flag | ||
|
||
if err := estimate(fs.Arg(0)); err != nil { | ||
if *recursiveFlag { | ||
err := recursiveEstimate(fs.Arg(0), *formatFlag) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} else if err := estimate(fs.Arg(0)); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this library is not packaged in debian too. it's not so important to have colorful output...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: golang-github-logrusorgru-aurora-dev
entered Debian on 2020-07-10