Skip to content

Commit

Permalink
feat: add remove parameter for call graph
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 15, 2019
1 parent cd309a7 commit b3c4667
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
"log"
"os/exec"
"strings"
)

var apiCmd *cobra.Command = &cobra.Command{
Expand All @@ -18,6 +19,7 @@ var apiCmd *cobra.Command = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
path := cmd.Flag("path").Value.String()
dependence := cmd.Flag("dependence").Value.String()
remove := cmd.Flag("remove").Value.String()

if path != "" {
app := new(JavaApiApp)
Expand All @@ -42,6 +44,10 @@ var apiCmd *cobra.Command = &cobra.Command{
analyser := domain.NewCallGraph()
dotContent := analyser.AnalysisByFiles(apiCallers, parsedDeps)

if remove != "" {
dotContent = strings.ReplaceAll(dotContent, remove, "")
}

WriteToFile("api.dot", dotContent)

cmd := exec.Command("dot", []string{"-Tsvg", "api.dot", "-o", "api.svg"}...)
Expand All @@ -58,4 +64,5 @@ func init() {

apiCmd.PersistentFlags().StringP("path", "p", "", "path")
apiCmd.PersistentFlags().StringP("dependence", "d", "", "get dependence file")
apiCmd.PersistentFlags().StringP("remove", "r", "", "remove package name")
}
1 change: 0 additions & 1 deletion cmd/call_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ var callGraphCmd *cobra.Command = &cobra.Command{
content = strings.ReplaceAll(content, remove, "")
}


WriteToFile("call.dot", content)

cmd := exec.Command("dot", []string{"-Tsvg", "call.dot", "-o", "call_demo.svg"}...)
Expand Down

0 comments on commit b3c4667

Please sign in to comment.