unified output (#14) (#40)

This commit is contained in:
root360-AndreasUlm
2019-09-15 08:38:18 +00:00
committed by Gitea
parent 1d233402fd
commit 7c024bcd69
24 changed files with 2866 additions and 12 deletions

View File

@ -35,6 +35,11 @@ var CmdIssues = cli.Command{
Name: "repo, r",
Usage: "Indicate one repository, optional when inside a gitea repository",
},
cli.StringFlag{
Name: "output, o",
Usage: outputUsage,
Destination: &output,
},
},
}
@ -91,8 +96,17 @@ func runIssuesList(ctx *cli.Context) error {
log.Fatal(err)
}
headers := []string{
"Index",
"Name",
"Updated",
"Title",
}
var values [][]string
if len(issues) == 0 {
fmt.Println("No issues left")
Output(output, headers, values)
return nil
}
@ -101,8 +115,17 @@ func runIssuesList(ctx *cli.Context) error {
if len(name) == 0 {
name = issue.Poster.UserName
}
fmt.Printf("#%d\t%s\t%s\t%s\n", issue.Index, name, issue.Updated.Format("2006-01-02 15:04:05"), issue.Title)
values = append(
values,
[]string{
strconv.FormatInt(issue.Index, 10),
name,
issue.Updated.Format("2006-01-02 15:04:05"),
issue.Title,
},
)
}
Output(output, headers, values)
return nil
}