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

refactor: remove duplicated code

上级 8a571398
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")
}
},
}
......
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")
},
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册