Exemplo n.º 1
0
func (r *MySQLRenderer) Render(tbl *Table) string {
	s := ""

	sectionBreak := "+"
	for _, colSize := range tbl.colSizes {
		sectionBreak += mystrings.Stretch("", '-', colSize+2)
		sectionBreak += "+"
	}
	sectionBreak += "\n"

	for _, row := range tbl.records {
		if tbl.IsComment(row) {
			continue
		}

		for colNum, col := range row {
			if colNum == 0 {
				s += "|"
			}
			if colNum < tbl.colCount {
				s += " "
				s += mystrings.Stretch(col, ' ', tbl.colSizes[colNum])
				s += " |"
			}
		}
		s += "\n"
	}

	if s != "" {
		s = sectionBreak + s + sectionBreak
	}

	return s
}
Exemplo n.º 2
0
func (r *MarkdownRenderer) Render(tbl *Table) string {
	s := ""

	for _, row := range tbl.records {
		if tbl.IsComment(row) {
			continue
		}

		for colNum, col := range row {
			if colNum == 0 {
				s += "|"
			}
			if colNum < tbl.colCount {
				s += " "
				s += mystrings.Stretch(col, ' ', tbl.colSizes[colNum])
				s += " |"
			}
		}
		s += "\n"
	}

	return s
}