mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-16 20:20:57 +01:00
Merge pull request #7 from TLINDEN/development
added --no-headers flag to disable header display in tabular modes
This commit is contained in:
@@ -25,13 +25,14 @@ import (
|
||||
)
|
||||
|
||||
const DefaultSeparator string = `(\s\s+|\t)`
|
||||
const Version string = "v1.0.14"
|
||||
const Version string = "v1.0.15"
|
||||
|
||||
var VERSION string // maintained by -x
|
||||
|
||||
type Config struct {
|
||||
Debug bool
|
||||
NoNumbering bool
|
||||
NoHeaders bool
|
||||
Columns string
|
||||
UseColumns []int
|
||||
Separator string
|
||||
|
||||
@@ -105,6 +105,7 @@ func Execute() {
|
||||
// options
|
||||
rootCmd.PersistentFlags().BoolVarP(&conf.Debug, "debug", "d", false, "Enable debugging")
|
||||
rootCmd.PersistentFlags().BoolVarP(&conf.NoNumbering, "no-numbering", "n", false, "Disable header numbering")
|
||||
rootCmd.PersistentFlags().BoolVarP(&conf.NoHeaders, "no-headers", "", false, "Disable header display")
|
||||
rootCmd.PersistentFlags().BoolVarP(&conf.NoColor, "no-color", "N", false, "Disable pattern highlighting")
|
||||
rootCmd.PersistentFlags().BoolVarP(&ShowVersion, "version", "V", false, "Print program version")
|
||||
rootCmd.PersistentFlags().BoolVarP(&conf.InvertMatch, "invert-match", "v", false, "select non-matching rows")
|
||||
|
||||
@@ -13,6 +13,7 @@ SYNOPSIS
|
||||
-v, --invert-match select non-matching rows
|
||||
-n, --no-numbering Disable header numbering
|
||||
-N, --no-color Disable pattern highlighting
|
||||
--no-headers Disable headers display
|
||||
-s, --separator string Custom field separator
|
||||
-k, --sort-by int Sort by column (default: 1)
|
||||
|
||||
@@ -87,6 +88,11 @@ DESCRIPTION
|
||||
|
||||
The numbering can be suppressed by using the -n option.
|
||||
|
||||
By default tablizer shows a header containing the names of each column.
|
||||
This can be disabled using the --no-headers option. Be aware that this
|
||||
only affects tabular output modes. Shell, Extended, Yaml and CSV output
|
||||
modes always use the column names.
|
||||
|
||||
By default, if a pattern has been speficied, matches will be
|
||||
highlighted. You can disable this behavior with the -N option.
|
||||
|
||||
@@ -293,6 +299,7 @@ Operational Flags:
|
||||
-v, --invert-match select non-matching rows
|
||||
-n, --no-numbering Disable header numbering
|
||||
-N, --no-color Disable pattern highlighting
|
||||
--no-headers Disable headers display
|
||||
-s, --separator string Custom field separator
|
||||
-k, --sort-by int Sort by column (default: 1)
|
||||
|
||||
|
||||
@@ -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 := ""
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "TABLIZER 1"
|
||||
.TH TABLIZER 1 "2023-01-23" "1" "User Commands"
|
||||
.TH TABLIZER 1 "2023-04-21" "1" "User Commands"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
@@ -151,6 +151,7 @@ tablizer \- Manipulate tabular output of other programs
|
||||
\& \-v, \-\-invert\-match select non\-matching rows
|
||||
\& \-n, \-\-no\-numbering Disable header numbering
|
||||
\& \-N, \-\-no\-color Disable pattern highlighting
|
||||
\& \-\-no\-headers Disable headers display
|
||||
\& \-s, \-\-separator string Custom field separator
|
||||
\& \-k, \-\-sort\-by int Sort by column (default: 1)
|
||||
\&
|
||||
@@ -234,6 +235,11 @@ the original order.
|
||||
.PP
|
||||
The numbering can be suppressed by using the \fB\-n\fR option.
|
||||
.PP
|
||||
By default tablizer shows a header containing the names of each
|
||||
column. This can be disabled using the \fB\-\-no\-headers\fR option. Be
|
||||
aware that this only affects tabular output modes. Shell, Extended,
|
||||
Yaml and \s-1CSV\s0 output modes always use the column names.
|
||||
.PP
|
||||
By default, if a \fBpattern\fR has been speficied, matches will be
|
||||
highlighted. You can disable this behavior with the \fB\-N\fR option.
|
||||
.PP
|
||||
|
||||
@@ -12,6 +12,7 @@ tablizer - Manipulate tabular output of other programs
|
||||
-v, --invert-match select non-matching rows
|
||||
-n, --no-numbering Disable header numbering
|
||||
-N, --no-color Disable pattern highlighting
|
||||
--no-headers Disable headers display
|
||||
-s, --separator string Custom field separator
|
||||
-k, --sort-by int Sort by column (default: 1)
|
||||
|
||||
@@ -90,6 +91,11 @@ the original order.
|
||||
|
||||
The numbering can be suppressed by using the B<-n> option.
|
||||
|
||||
By default tablizer shows a header containing the names of each
|
||||
column. This can be disabled using the B<--no-headers> option. Be
|
||||
aware that this only affects tabular output modes. Shell, Extended,
|
||||
Yaml and CSV output modes always use the column names.
|
||||
|
||||
By default, if a B<pattern> has been speficied, matches will be
|
||||
highlighted. You can disable this behavior with the B<-N> option.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user