diff --git a/cmd/call.go b/cmd/call.go index a6a5ca759830aa08f781c37964a64230349d4f6a..8115a9afabc7823c2b715de69121d9e453267a37 100644 --- a/cmd/call.go +++ b/cmd/call.go @@ -1,14 +1,14 @@ package cmd import ( + "encoding/json" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/config" . "github.com/phodal/coca/core/domain/call_graph" "github.com/phodal/coca/core/models" . "github.com/phodal/coca/core/support" - "encoding/json" "github.com/spf13/cobra" "log" - "os/exec" "strings" ) @@ -46,12 +46,7 @@ var callGraphCmd = &cobra.Command{ } WriteToCocaFile("call.dot", content) - - cmd := exec.Command("dot", []string{"-Tsvg", config.CocaConfig.ReporterPath + "/call.dot", "-o", config.CocaConfig.ReporterPath + "/call.svg"}...) - _, err := cmd.CombinedOutput() - if err != nil { - log.Fatalf("cmd.Run() failed with %s\n", err) - } + cmd_util.ConvertToSvg("call") } }, } diff --git a/cmd/rcall.go b/cmd/rcall.go index 07a5acdc94a5f453492a3c58afa3c949a8a771b9..5751b18b1b3729393f4cae28474e096253422833 100644 --- a/cmd/rcall.go +++ b/cmd/rcall.go @@ -1,14 +1,14 @@ package cmd import ( + "encoding/json" + "fmt" + "github.com/phodal/coca/cmd/cmd_util" "github.com/phodal/coca/config" "github.com/phodal/coca/core/domain/call_graph/rcall" . "github.com/phodal/coca/core/support" - "encoding/json" - "fmt" "github.com/spf13/cobra" "log" - "os/exec" "strings" ) @@ -51,12 +51,7 @@ var reverseCmd = &cobra.Command{ } WriteToCocaFile("rcall.dot", content) - - acmd := exec.Command("dot", []string{"-Tsvg", config.CocaConfig.ReporterPath + "/rcall.dot", "-o", config.CocaConfig.ReporterPath + "/rcall.svg"}...) - output, err := acmd.CombinedOutput() - if err != nil { - log.Fatalf("cmd.Run() failed with %s%s\n", err, string(output)) - } + cmd_util.ConvertToSvg("call") }, }