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

feat: make todos works

上级 c519f3d9
......@@ -308,6 +308,31 @@ early [earlyRemoveWithException earlyRemoveAllWithException earlyRemoveAll early
evict [evictAll evictWithException evict evictEarly evictAllEarly]
```
### Todo
```
coca todo
```
results:
```
+------------+--------------+--------------------------------+---------------------------------------------------+-------+
| DATE | AUTHOR | MESSAGES | FILENAME | LINE |
+------------+--------------+--------------------------------+---------------------------------------------------+-------+
| 2019-12-19 | Phodal Huang | 支持 interface 在同一个包内 | core/adapter/api/JavaApiListener.go | 200 |
| 2019-12-21 | Phodal Huang | 处理链试调用 | core/adapter/bs/BadSmellListener.go | 305 |
| 2019-12-18 | Phodal Huang | update this reflect | core/adapter/bs/BadSmellListener.go | 363 |
| 2019-12-15 | Phodal Huang | update for array | core/adapter/bs/BadSmellListener.go | 388 |
| 2019-12-24 | Phodal Huang | 支持依赖注入 | core/adapter/call/JavaCallListener.go | 108 |
| 2019-12-24 | Phodal Huang | add inner creator examples | core/adapter/call/JavaCallListener.go | 209 |
| 2019-12-24 | Phodal Huang | add inner creator examples | core/adapter/call/JavaCallListener.go | 215 |
| 2019-12-24 | Phodal Huang | | core/adapter/call/JavaCallListener.go | 270 |
| 2019-12-20 | Phodal Huang | 处理链试调用 | core/adapter/call/JavaCallListener.go | 324 |
+------------+--------------+--------------------------------+---------------------------------------------------+-------+
```
## Dev
Install Go
......
package cmd
import (
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/core/domain/todo"
"github.com/spf13/cobra"
"os"
"strings"
)
type RootCmdConfig struct {
......@@ -21,7 +24,15 @@ var todoCmd = &cobra.Command{
path := cmd.Flag("path").Value.String()
if path != "" {
app := todo.NewTodoApp()
app.AnalysisPath(path)
todos := app.AnalysisPath(path)
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Date", "Author", "Messages", "FileName", "Line"})
for _, todo := range todos {
table.Append([]string{todo.Date, todo.Author, strings.Join(todo.Message, "\n"), todo.FileName, todo.Line})
}
table.Render()
}
},
}
......
package todo
import (
"fmt"
"github.com/phodal/coca/core/domain/gitt"
"github.com/phodal/coca/core/domain/todo/astitodo"
"log"
......@@ -19,7 +18,17 @@ func NewTodoApp() TodoApp {
}
}
func (a TodoApp) AnalysisPath(path string) {
type TodoDetail struct {
Date string
FileName string
Author string
Line string
Assignee string
Message []string
}
func (a TodoApp) AnalysisPath(path string) []TodoDetail {
var todoList []TodoDetail = nil
todos, err := astitodo.Extract(path)
if err != nil {
log.Fatal(err)
......@@ -27,12 +36,25 @@ func (a TodoApp) AnalysisPath(path string) {
for _, todo := range todos {
lineOutput := runGitGetLog(todo.Line, todo.Filename)
todoDetail := &TodoDetail{
Date: "",
FileName: todo.Filename,
Author: "",
Line: strconv.Itoa(todo.Line),
Assignee: todo.Assignee,
Message: todo.Message,
}
commitMessages := gitt.BuildMessageByInput(lineOutput)
if len(commitMessages) > 0 {
commit := commitMessages[0]
fmt.Println(commit.Date, todo.Filename, commit.Author, todo.Line)
todoDetail.Date = commit.Date
todoDetail.Author = commit.Author
}
todoList = append(todoList, *todoDetail)
}
return todoList
}
func runGitGetLog(line int, fileName string) string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册