未验证 提交 73e24cb9 编写于 作者: P Phodal Huang

refactor: remove duplicated code

上级 8a571398
package cmd package cmd
import ( import (
"encoding/json"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/config" "github.com/phodal/coca/config"
. "github.com/phodal/coca/core/domain/call_graph" . "github.com/phodal/coca/core/domain/call_graph"
"github.com/phodal/coca/core/models" "github.com/phodal/coca/core/models"
. "github.com/phodal/coca/core/support" . "github.com/phodal/coca/core/support"
"encoding/json"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"log" "log"
"os/exec"
"strings" "strings"
) )
...@@ -46,12 +46,7 @@ var callGraphCmd = &cobra.Command{ ...@@ -46,12 +46,7 @@ var callGraphCmd = &cobra.Command{
} }
WriteToCocaFile("call.dot", content) WriteToCocaFile("call.dot", content)
cmd_util.ConvertToSvg("call")
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)
}
} }
}, },
} }
......
package cmd package cmd
import ( import (
"encoding/json"
"fmt"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/config" "github.com/phodal/coca/config"
"github.com/phodal/coca/core/domain/call_graph/rcall" "github.com/phodal/coca/core/domain/call_graph/rcall"
. "github.com/phodal/coca/core/support" . "github.com/phodal/coca/core/support"
"encoding/json"
"fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"log" "log"
"os/exec"
"strings" "strings"
) )
...@@ -51,12 +51,7 @@ var reverseCmd = &cobra.Command{ ...@@ -51,12 +51,7 @@ var reverseCmd = &cobra.Command{
} }
WriteToCocaFile("rcall.dot", content) WriteToCocaFile("rcall.dot", content)
cmd_util.ConvertToSvg("call")
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))
}
}, },
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册