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

feat: add size for gitt

上级 1b5809d2
......@@ -21,6 +21,12 @@ var gitCmd *cobra.Command = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
message := BuildCommitMessage()
isFullMessage := cmd.Flag("basic").Value.String() == "true"
size := cmd.Flag("size").Value.String()
intSize, err := strconv.Atoi(size)
if err != nil {
intSize = 20
}
if cmd.Flag("basic").Value.String() == "true" {
table := tablewriter.NewWriter(os.Stdout)
......@@ -40,8 +46,8 @@ var gitCmd *cobra.Command = &cobra.Command{
teamSummary := GetTeamSummary(message)
table.SetHeader([]string{"EntityName", "RevsCount", "AuthorCount"})
if len(teamSummary) > 20 && isFullMessage {
teamSummary = teamSummary[:20]
if len(teamSummary) > intSize && isFullMessage {
teamSummary = teamSummary[:intSize]
}
for _, v := range teamSummary {
table.Append([]string{v.EntityName, strconv.Itoa(v.RevsCount), strconv.Itoa(v.AuthorCount)})
......@@ -55,8 +61,8 @@ var gitCmd *cobra.Command = &cobra.Command{
age := CalculateCodeAge(message)
table.SetHeader([]string{"File", "Month"})
if len(age) > 20 && isFullMessage {
age = age[:20]
if len(age) > intSize && isFullMessage {
age = age[:intSize]
}
for _, v := range age {
table.Append([]string{v.File, v.Month})
......@@ -70,8 +76,8 @@ var gitCmd *cobra.Command = &cobra.Command{
authors := GetTopAuthors(message)
table.SetHeader([]string{"Author", "CommitCount", "LineCount"})
if len(authors) > 20 && isFullMessage {
authors = authors[:20]
if len(authors) > intSize && isFullMessage {
authors = authors[:intSize]
}
for _, v := range authors {
table.Append([]string{v.Name, strconv.Itoa(v.CommitCount), strconv.Itoa(v.LineCount)})
......@@ -101,5 +107,6 @@ func init() {
gitCmd.PersistentFlags().BoolP("age", "a", false, "Code Age")
gitCmd.PersistentFlags().BoolP("top", "o", false, "Top Authors")
gitCmd.PersistentFlags().BoolP("full", "f", false, "full")
gitCmd.PersistentFlags().IntP("size", "s", 20, "full")
gitCmd.PersistentFlags().StringVar(&relatedConfig, "r", "", "related")
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册