mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-17 20:41:03 +01:00
added --no-headers flag to disable header display in tabular modes
This commit is contained in:
@@ -69,13 +69,15 @@ func output(w io.Writer, str string) {
|
||||
}
|
||||
|
||||
/*
|
||||
Emacs org-mode compatible table (also orgtbl-mode)
|
||||
Emacs org-mode compatible table (also orgtbl-mode)
|
||||
*/
|
||||
func printOrgmodeData(w io.Writer, c cfg.Config, data *Tabdata) {
|
||||
tableString := &strings.Builder{}
|
||||
table := tablewriter.NewWriter(tableString)
|
||||
|
||||
table.SetHeader(data.headers)
|
||||
if !c.NoHeaders {
|
||||
table.SetHeader(data.headers)
|
||||
}
|
||||
|
||||
for _, row := range data.entries {
|
||||
table.Append(trimRow(row))
|
||||
@@ -104,13 +106,15 @@ func printOrgmodeData(w io.Writer, c cfg.Config, data *Tabdata) {
|
||||
}
|
||||
|
||||
/*
|
||||
Markdown table
|
||||
Markdown table
|
||||
*/
|
||||
func printMarkdownData(w io.Writer, c cfg.Config, data *Tabdata) {
|
||||
tableString := &strings.Builder{}
|
||||
table := tablewriter.NewWriter(tableString)
|
||||
|
||||
table.SetHeader(data.headers)
|
||||
if !c.NoHeaders {
|
||||
table.SetHeader(data.headers)
|
||||
}
|
||||
|
||||
for _, row := range data.entries {
|
||||
table.Append(trimRow(row))
|
||||
@@ -124,19 +128,17 @@ func printMarkdownData(w io.Writer, c cfg.Config, data *Tabdata) {
|
||||
}
|
||||
|
||||
/*
|
||||
Simple ASCII table without any borders etc, just like the input we expect
|
||||
Simple ASCII table without any borders etc, just like the input we expect
|
||||
*/
|
||||
func printAsciiData(w io.Writer, c cfg.Config, data *Tabdata) {
|
||||
tableString := &strings.Builder{}
|
||||
table := tablewriter.NewWriter(tableString)
|
||||
|
||||
table.SetHeader(data.headers)
|
||||
if !c.NoHeaders {
|
||||
table.SetHeader(data.headers)
|
||||
}
|
||||
table.AppendBulk(data.entries)
|
||||
|
||||
// for _, row := range data.entries {
|
||||
// table.Append(trimRow(row))
|
||||
// }
|
||||
|
||||
table.SetAutoWrapText(false)
|
||||
table.SetAutoFormatHeaders(true)
|
||||
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
@@ -154,7 +156,7 @@ func printAsciiData(w io.Writer, c cfg.Config, data *Tabdata) {
|
||||
}
|
||||
|
||||
/*
|
||||
We simulate the \x command of psql (the PostgreSQL client)
|
||||
We simulate the \x command of psql (the PostgreSQL client)
|
||||
*/
|
||||
func printExtendedData(w io.Writer, c cfg.Config, data *Tabdata) {
|
||||
// needed for data output
|
||||
@@ -174,7 +176,7 @@ func printExtendedData(w io.Writer, c cfg.Config, data *Tabdata) {
|
||||
}
|
||||
|
||||
/*
|
||||
Shell output, ready to be eval'd. Just like FreeBSD stat(1)
|
||||
Shell output, ready to be eval'd. Just like FreeBSD stat(1)
|
||||
*/
|
||||
func printShellData(w io.Writer, c cfg.Config, data *Tabdata) {
|
||||
out := ""
|
||||
|
||||
Reference in New Issue
Block a user