未验证 提交 5af5fa66 编写于 作者: P Phodal Huang

refactor: move write file to cmd

上级 3a5982a9
package cmd
import (
"bufio"
"github.com/phodal/coca/cmd/cmd_util"
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/adapter"
"github.com/phodal/coca/core/domain/arch"
"github.com/spf13/cobra"
"os"
"strings"
)
......@@ -39,7 +41,12 @@ var archCmd = &cobra.Command{
return false
}
dotContent.ToDot("coca_reporter/arch.dot", ".", nodeFilter)
graph := dotContent.ToDot(".", nodeFilter)
f, _ := os.Create("coca_reporter/arch.dot")
w := bufio.NewWriter(f)
w.WriteString("di" + graph.String())
w.Flush()
cmd_util.ConvertToSvg("arch")
},
}
......
package tequila
import (
"bufio"
"fmt"
"github.com/awalterschulze/gographviz"
"io/ioutil"
......@@ -232,7 +231,7 @@ func ParseInclude(codeDir string) *FullGraph {
return fullGraph
}
func (fullGraph *FullGraph) ToDot(fileName string, split string, filter func(string) bool) {
func (fullGraph *FullGraph) ToDot(split string, filter func(string) bool) *gographviz.Graph {
graph := gographviz.NewGraph()
graph.SetName("G")
......@@ -294,10 +293,7 @@ func (fullGraph *FullGraph) ToDot(fileName string, split string, filter func(str
}
}
f, _ := os.Create(fileName)
w := bufio.NewWriter(f)
w.WriteString("di" + graph.String())
w.Flush()
return graph
}
var Foo = func() string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册