@@ -4,11 +4,14 @@ import (
44" fmt"
55" github.com/boyter/scc/processor"
66" github.com/phodal/coca/cmd/config"
7+ " github.com/phodal/coca/pkg/domain/cloc"
78" github.com/spf13/cobra"
9+ " gopkg.in/yaml.v2"
810" io/ioutil"
911" log"
1012" os"
1113" path/filepath"
14+ " strings"
1215)
1316
1417type CocaClocConfig struct {
@@ -42,15 +45,35 @@ var clocCmd = &cobra.Command{
4245
4346processor.Format =" cloc-yaml"
4447
48+ var outputFiles []string
4549for _, dir := range dirs {
4650baseName := filepath.Base (dir)
51+ if baseName ==" .git" || baseName ==" .svn" || baseName ==" .hg" {
52+ continue
53+ }
4754processor.DirFilePaths = []string{dir}
48- processor.FileOutput = filepath.FromSlash (config.CocaConfig .ReporterPath +" /cloc/" + baseName +" .yaml" )
55+ outputFile := filepath.FromSlash (config.CocaConfig .ReporterPath +" /cloc/" + baseName +" .yaml" )
56+ outputFiles =append (outputFiles, outputFile)
57+ processor.FileOutput = outputFile
4958processor.ConfigureGc ()
5059processor.ConfigureLazy (true )
5160processor.Process ()
5261}
5362
63+ var summaryMap =make (map[string]cloc.ClocSummary )
64+ for _, file := range outputFiles {
65+ var summary = cloc.ClocSummary {}
66+ contents, _ := ioutil.ReadFile (file)
67+ baseName := strings.TrimSuffix (filepath.Base (file), filepath.Ext (file))
68+ err := yaml.Unmarshal (contents, &summary)
69+ if err != nil {
70+ panic (err);
71+ }
72+ summaryMap[baseName] = summary
73+ }
74+
75+ fmt.Println (summaryMap)
76+
5477return
5578}else {
5679processor.DirFilePaths = args