func main() {
	// Building demo report
	demo := reports.NewReport("Demo report", "demo")

	// Building chunk of data
	ch := reports.NewChunk("Chunk #1", "This is example chunk")
	ch.AddHeaders("Name", "Integers", "Floats")
	ch.AddRow("Foo", 15, 0.3)
	ch.AddRow("Foo 0", 0, "")

	ch.AddRow("Log bar", 15863, 1.001)
	ch.AddRow("Third one", reports.NewCell(-82, "", reports.MARKER_HIGHLIGHT), 1.001)
	ch.AddRow("4", reports.NewCell(-82, "", reports.MARKER_POSITIVE), 8.9)
	ch.AddRow("*****", reports.NewFloatCell(-82, 3, "", reports.MARKER_NEGATIVE), 91.2735)

	demo.Add(*ch)

	if len(os.Args) > 1 {
		// Printing to file
		demo.SaveToFile(os.Args[1])
	} else {
		// Colors
		cli.ReportPrinter(nil, 0, true)(*demo)

		// No colors
		cli.ReportPrinter(nil, 0, false)(*demo)
	}
}
Beispiel #2
0
func main() {
	if len(os.Args) < 2 {
		fmt.Println("Usage: catgr <reportfile> [detail level]")
		fmt.Println("")
		os.Exit(1)
	}

	filename := os.Args[1]
	bts, err := ioutil.ReadFile(filename)
	if err != nil {
		fmt.Println("Unable to read file", filename)
		fmt.Println("")
		os.Exit(1)
	}

	r, err := reports.UnpackReport(bts)
	if err != nil {
		fmt.Println("Unable to unpack report from", filename)
		fmt.Println("")
		os.Exit(1)
	}

	detail := 0
	if len(os.Args) > 2 {
		detail, _ = strconv.Atoi(os.Args[2])
	}

	cli.ReportPrinter(nil, int8(detail), true)(*r)
}
Beispiel #3
0
func main() {

	r := reports.NewReport("ololo", "trololo")

	ch := reports.NewChunk("Chunk #1", "This is example chunk")
	ch.AddHeaders("Name", "Integers", "Floats")
	ch.AddRow("Foo", 15, 0.3)
	ch.AddRow("Foo 0", 0, "")
	ch.AddRow("Log bar", 15863, 1.001)
	ch.AddRow("Third one", reports.NewCell(-82, "", reports.MARKER_HIGHLIGHT), 1.001)
	ch.AddRow("4", reports.NewCell(-82, "", reports.MARKER_POSITIVE), 8.9)
	ch.AddRow("*****", reports.NewFloatCell(-82, 3, "", reports.MARKER_NEGATIVE), 91.2735)

	r.Add(*ch)

	cli.ReportPrinter(nil, 0, true)(*r)

	b0 := reports.PackReport(*r)
	rrrr, err := reports.UnpackReport(b0)
	if err != nil {
		panic(err)
	}

	cli.ReportPrinter(nil, 0, true)(*rrrr)

	// Writing
	r.SaveToFile("test.gr")

	// Reading
	bts, _ := ioutil.ReadFile("test.gr")
	r2, err := reports.UnpackReport(bts)
	if err != nil {
		panic(err)
	}

	cli.ReportPrinter(nil, 0, true)(*r2)
}