Lots of small stuff

This commit is contained in:
Olivier Tremblay 2016-05-11 09:44:12 -04:00
commit b5c1189de8
No known key found for this signature in database
GPG key ID: 1A9FE7C1DFF65CB0
14 changed files with 911 additions and 0 deletions

30
cmd/jkl/list.go Normal file
View file

@ -0,0 +1,30 @@
package main
import (
"flag"
"os"
"strings"
"text/template"
"otremblay.com/jkl"
)
var listTemplateStr string
var listTemplate *template.Template
func init() {
flag.StringVar(&listTemplateStr, "listTemplate", "{{.Key}}\t({{.Fields.IssueType.Name}}{{if .Fields.Parent}} of {{.Fields.Parent.Key}}{{end}})\t{{.Fields.Summary}}\n", "Go template used in list command")
listTemplate = template.Must(template.New("listTemplate").Parse(listTemplateStr))
}
func List(args []string) error {
if issues, err := jkl.List(strings.Join(args, " ")); err != nil {
return err
} else {
for _, issue := range issues {
listTemplate.Execute(os.Stdout, issue)
}
}
return nil
}