Ejemplo n.º 1
0
func PrintHtml(issues []*Issue) ([]byte, error) {
	var bs []byte
	out := bytes.NewBuffer(bs)
	var tmpl *mustache.Template
	tmpl, err := mustache.ParseString(defaultTemplate)

	if err != nil {
		return out.Bytes(), err
	}
	fmt.Fprintln(out, tmpl.Render(map[string]interface{}{"Issues": issues}))
	return out.Bytes(), err

}
Ejemplo n.º 2
0
func (te *MustacheTemplateEngine) Render(filepath string, layoutPath string, viewData *goku.ViewData, wr io.Writer) {
	var tmpl *mustache.Template
	tmpl = te.getTemplate(filepath)

	var r string
	if te.SupportLayout() && layoutPath != "" {
		layout := te.getTemplate(layoutPath)

		r = tmpl.RenderInLayout(layout, viewData)
	} else {
		r = tmpl.Render(viewData)
	}
	wr.Write([]byte(r))
}
Ejemplo n.º 3
0
//Implements go-flags's Command interface
func (lc *ListCommand) Execute(args []string) error { //ListTasks(){//
	if options.Verbose {
		fmt.Println("In List Command")
	}
	jc := libgojira.NewJiraClient(options)
	if len(args) == 1 && (!lc.Open && !lc.CurrentSprint && lc.JQL == "") {
		lc.JQL = fmt.Sprintf("key = %s or parent = %s order by rank", args[0], args[0])
	}
	issues, err := jc.Search(&libgojira.SearchOptions{options.Projects, lc.CurrentSprint, lc.Open, lc.Issue, lc.JQL, lc.Type, lc.NotType, lc.Status, lc.NotStatus})
	if err != nil {
		return err
	}
	if lc.Print {
		var tmpl *mustache.Template
		if lc.PrintTmpl != "" {
			tmpl, err = mustache.ParseFile(lc.PrintTmpl)
			fmt.Fprintln(out, tmpl.Render(map[string]interface{}{"Issues": issues}))
		} else {
			html, _ := libgojira.PrintHtml(issues)
			fmt.Fprintln(out, string(html))
		}
	} else {
		if lc.TotalTime {
			fmt.Fprintln(out, "ID,Points,Type,Est.,Spent,Rem.,Desc.")
			for _, v := range issues {
				fmt.Fprintln(out, fmt.Sprintf("%s,%s,%s,%s,%s,%s,\"%s\"", v.Key, v.Points, v.Type, libgojira.PrettySeconds(int(v.OriginalEstimate)), libgojira.PrettySeconds(int(v.TimeSpent)), libgojira.PrettySeconds(int(v.RemainingEstimate)), v.Summary))
			}
		} else {
			for _, v := range issues {
				fmt.Fprintln(out, v)
			}
		}
	}

	return nil
}