mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-17 12:31:06 +01:00
Made corrections to satisfy linter.
This commit is contained in:
1
Makefile
1
Makefile
@@ -36,6 +36,7 @@ all: $(tool).1 cmd/$(tool).go buildlocal
|
|||||||
|
|
||||||
cmd/%.go: %.pod
|
cmd/%.go: %.pod
|
||||||
echo "package cmd" > cmd/$*.go
|
echo "package cmd" > cmd/$*.go
|
||||||
|
echo >> cmd/$*.go
|
||||||
echo "var manpage = \`" >> cmd/$*.go
|
echo "var manpage = \`" >> cmd/$*.go
|
||||||
pod2text $*.pod >> cmd/$*.go
|
pod2text $*.pod >> cmd/$*.go
|
||||||
echo "\`" >> cmd/$*.go
|
echo "\`" >> cmd/$*.go
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
[](https://github.com/tlinden/tablizer/actions)
|
[](https://github.com/tlinden/tablizer/actions)
|
||||||
[](https://github.com/tlinden/tablizer/blob/master/LICENSE)
|
[](https://github.com/tlinden/tablizer/blob/master/LICENSE)
|
||||||
|
[](https://goreportcard.com/report/github.com/tlinden/tablizer)
|
||||||
|
|
||||||
## tablizer - Manipulate tabular output of other programs
|
## tablizer - Manipulate tabular output of other programs
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
var manpage = `
|
var manpage = `
|
||||||
NAME
|
NAME
|
||||||
tablizer - Manipulate tabular output of other programs
|
tablizer - Manipulate tabular output of other programs
|
||||||
@@ -37,7 +38,7 @@ DESCRIPTION
|
|||||||
|
|
||||||
You can use tablizer to do these and more things.
|
You can use tablizer to do these and more things.
|
||||||
|
|
||||||
tablizer analyses the header fiels of a table, registers the column
|
tablizer analyses the header fields of a table, registers the column
|
||||||
positions of each header field and separates columns by those positions.
|
positions of each header field and separates columns by those positions.
|
||||||
|
|
||||||
Without any options it reads its input from "STDIN", but you can also
|
Without any options it reads its input from "STDIN", but you can also
|
||||||
@@ -79,7 +80,7 @@ DESCRIPTION
|
|||||||
(as in GNU sort(1)). The default sort column is the first one. To
|
(as in GNU sort(1)). The default sort column is the first one. To
|
||||||
disable sorting at all, supply 0 (Zero) to -k.
|
disable sorting at all, supply 0 (Zero) to -k.
|
||||||
|
|
||||||
Finally the -d option enables debugging output which is mostly usefull
|
Finally the -d option enables debugging output which is mostly useful
|
||||||
for the developer.
|
for the developer.
|
||||||
|
|
||||||
PATTERNS
|
PATTERNS
|
||||||
@@ -102,14 +103,14 @@ DESCRIPTION
|
|||||||
|
|
||||||
"i" ignore case "m" multiline mode "s" single line mode
|
"i" ignore case "m" multiline mode "s" single line mode
|
||||||
|
|
||||||
Example for a case insensitve search:
|
Example for a case insensitive search:
|
||||||
|
|
||||||
kubectl get pods -A | tablizer "(?i)account"
|
kubectl get pods -A | tablizer "(?i)account"
|
||||||
|
|
||||||
OUTPUT MODES
|
OUTPUT MODES
|
||||||
There might be cases when the tabular output of a program is way too
|
There might be cases when the tabular output of a program is way too
|
||||||
large for your current terminal but you still need to see every column.
|
large for your current terminal but you still need to see every column.
|
||||||
In such cases the -o extended or -X option can be usefull which enables
|
In such cases the -o extended or -X option can be useful which enables
|
||||||
*extended mode*. In this mode, each row will be printed vertically,
|
*extended mode*. In this mode, each row will be printed vertically,
|
||||||
header left, value right, aligned by the field widths. Here's an
|
header left, value right, aligned by the field widths. Here's an
|
||||||
example:
|
example:
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ var (
|
|||||||
|
|
||||||
// colors to be used per supported color mode
|
// colors to be used per supported color mode
|
||||||
Colors = map[color.Level]map[string]string{
|
Colors = map[color.Level]map[string]string{
|
||||||
color.Level16: map[string]string{
|
color.Level16: {
|
||||||
"bg": "green", "fg": "black",
|
"bg": "green", "fg": "black",
|
||||||
},
|
},
|
||||||
color.Level256: map[string]string{
|
color.Level256: {
|
||||||
"bg": "lightGreen", "fg": "black",
|
"bg": "lightGreen", "fg": "black",
|
||||||
},
|
},
|
||||||
color.LevelRgb: map[string]string{
|
color.LevelRgb: {
|
||||||
// FIXME: maybe use something nicer
|
// FIXME: maybe use something nicer
|
||||||
"bg": "lightGreen", "fg": "black",
|
"bg": "lightGreen", "fg": "black",
|
||||||
},
|
},
|
||||||
@@ -68,7 +68,7 @@ var (
|
|||||||
validOutputmodes = "(orgtbl|markdown|extended|ascii)"
|
validOutputmodes = "(orgtbl|markdown|extended|ascii)"
|
||||||
|
|
||||||
// main program version
|
// main program version
|
||||||
Version = "v1.0.8"
|
Version = "v1.0.9"
|
||||||
|
|
||||||
// generated version string, used by -v contains lib.Version on
|
// generated version string, used by -v contains lib.Version on
|
||||||
// main branch, and lib.Version-$branch-$lastcommit-$date on
|
// main branch, and lib.Version-$branch-$lastcommit-$date on
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ func reduceColumns(data *Tabdata) {
|
|||||||
// exclude columns, if any
|
// exclude columns, if any
|
||||||
if len(Columns) > 0 {
|
if len(Columns) > 0 {
|
||||||
reducedEntries := [][]string{}
|
reducedEntries := [][]string{}
|
||||||
reducedEntry := []string{}
|
var reducedEntry []string
|
||||||
for _, entry := range data.entries {
|
for _, entry := range data.entries {
|
||||||
reducedEntry = nil
|
reducedEntry = nil
|
||||||
for i, value := range entry {
|
for i, value := range entry {
|
||||||
|
|||||||
@@ -79,15 +79,15 @@ func TestReduceColumns(t *testing.T) {
|
|||||||
columns []int
|
columns []int
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
expect: [][]string{[]string{"a", "b"}},
|
expect: [][]string{{"a", "b"}},
|
||||||
columns: []int{1, 2},
|
columns: []int{1, 2},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
expect: [][]string{[]string{"a", "c"}},
|
expect: [][]string{{"a", "c"}},
|
||||||
columns: []int{1, 3},
|
columns: []int{1, 3},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
expect: [][]string{[]string{"a"}},
|
expect: [][]string{{"a"}},
|
||||||
columns: []int{1},
|
columns: []int{1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -96,7 +96,7 @@ func TestReduceColumns(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
input := [][]string{[]string{"a", "b", "c"}}
|
input := [][]string{{"a", "b", "c"}}
|
||||||
|
|
||||||
Columns = "y" // used as a flag with len(Columns)...
|
Columns = "y" // used as a flag with len(Columns)...
|
||||||
|
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ func TestParser(t *testing.T) {
|
|||||||
"ONE", "TWO", "THREE",
|
"ONE", "TWO", "THREE",
|
||||||
},
|
},
|
||||||
entries: [][]string{
|
entries: [][]string{
|
||||||
[]string{
|
{
|
||||||
"asd", "igig", "cxxxncnc",
|
"asd", "igig", "cxxxncnc",
|
||||||
},
|
},
|
||||||
[]string{
|
{
|
||||||
"19191", "EDD 1", "X",
|
"19191", "EDD 1", "X",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -69,7 +69,7 @@ func TestParserPatternmatching(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
entries: [][]string{
|
entries: [][]string{
|
||||||
[]string{
|
{
|
||||||
"asd", "igig", "cxxxncnc",
|
"asd", "igig", "cxxxncnc",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -78,7 +78,7 @@ func TestParserPatternmatching(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
entries: [][]string{
|
entries: [][]string{
|
||||||
[]string{
|
{
|
||||||
"19191", "EDD 1", "X",
|
"19191", "EDD 1", "X",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ func TestPrinter(t *testing.T) {
|
|||||||
"ONE", "TWO", "THREE",
|
"ONE", "TWO", "THREE",
|
||||||
},
|
},
|
||||||
entries: [][]string{
|
entries: [][]string{
|
||||||
[]string{
|
{
|
||||||
"asd", "igig", "cxxxncnc",
|
"asd", "igig", "cxxxncnc",
|
||||||
},
|
},
|
||||||
[]string{
|
{
|
||||||
"19191", "EDD 1", "X",
|
"19191", "EDD 1", "X",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -100,7 +100,9 @@ THREE(3): X`,
|
|||||||
t.Run(testname, func(t *testing.T) {
|
t.Run(testname, func(t *testing.T) {
|
||||||
|
|
||||||
OutputMode = mode
|
OutputMode = mode
|
||||||
data := startdata // we need to reset our mock data, since it's being modified in printData()
|
// we need to reset our mock data, since it's being
|
||||||
|
// modified in printData()
|
||||||
|
data := startdata
|
||||||
printData(&data)
|
printData(&data)
|
||||||
|
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
@@ -136,13 +138,13 @@ func TestSortPrinter(t *testing.T) {
|
|||||||
"ONE", "TWO", "THREE",
|
"ONE", "TWO", "THREE",
|
||||||
},
|
},
|
||||||
entries: [][]string{
|
entries: [][]string{
|
||||||
[]string{
|
{
|
||||||
"abc", "345", "b1",
|
"abc", "345", "b1",
|
||||||
},
|
},
|
||||||
[]string{
|
{
|
||||||
"bcd", "234", "a2",
|
"bcd", "234", "a2",
|
||||||
},
|
},
|
||||||
[]string{
|
{
|
||||||
"cde", "123", "c3",
|
"cde", "123", "c3",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
12
tablizer.1
12
tablizer.1
@@ -133,7 +133,7 @@
|
|||||||
.\" ========================================================================
|
.\" ========================================================================
|
||||||
.\"
|
.\"
|
||||||
.IX Title "TABLIZER 1"
|
.IX Title "TABLIZER 1"
|
||||||
.TH TABLIZER 1 "2022-10-13" "1" "User Commands"
|
.TH TABLIZER 1 "2022-10-14" "1" "User Commands"
|
||||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||||
.\" way too many mistakes in technical documents.
|
.\" way too many mistakes in technical documents.
|
||||||
.if n .ad l
|
.if n .ad l
|
||||||
@@ -177,8 +177,8 @@ not easy to process.
|
|||||||
.PP
|
.PP
|
||||||
You can use \fBtablizer\fR to do these and more things.
|
You can use \fBtablizer\fR to do these and more things.
|
||||||
.PP
|
.PP
|
||||||
\&\fBtablizer\fR analyses the header fiels of a table, registers the column
|
\&\fBtablizer\fR analyses the header fields of a table, registers the
|
||||||
positions of each header field and separates columns by those
|
column positions of each header field and separates columns by those
|
||||||
positions.
|
positions.
|
||||||
.PP
|
.PP
|
||||||
Without any options it reads its input from \f(CW\*(C`STDIN\*(C'\fR, but you can also
|
Without any options it reads its input from \f(CW\*(C`STDIN\*(C'\fR, but you can also
|
||||||
@@ -228,7 +228,7 @@ data (as in \s-1GNU\s0 \fBsort\fR\|(1)). The default sort column is the first on
|
|||||||
disable sorting at all, supply 0 (Zero) to \-k.
|
disable sorting at all, supply 0 (Zero) to \-k.
|
||||||
.PP
|
.PP
|
||||||
Finally the \fB\-d\fR option enables debugging output which is mostly
|
Finally the \fB\-d\fR option enables debugging output which is mostly
|
||||||
usefull for the developer.
|
useful for the developer.
|
||||||
.SS "\s-1PATTERNS\s0"
|
.SS "\s-1PATTERNS\s0"
|
||||||
.IX Subsection "PATTERNS"
|
.IX Subsection "PATTERNS"
|
||||||
You can reduce the rows being displayed by using a regular expression
|
You can reduce the rows being displayed by using a regular expression
|
||||||
@@ -256,7 +256,7 @@ The most important modifiers are:
|
|||||||
\&\f(CW\*(C`m\*(C'\fR multiline mode
|
\&\f(CW\*(C`m\*(C'\fR multiline mode
|
||||||
\&\f(CW\*(C`s\*(C'\fR single line mode
|
\&\f(CW\*(C`s\*(C'\fR single line mode
|
||||||
.PP
|
.PP
|
||||||
Example for a case insensitve search:
|
Example for a case insensitive search:
|
||||||
.PP
|
.PP
|
||||||
.Vb 1
|
.Vb 1
|
||||||
\& kubectl get pods \-A | tablizer "(?i)account"
|
\& kubectl get pods \-A | tablizer "(?i)account"
|
||||||
@@ -266,7 +266,7 @@ Example for a case insensitve search:
|
|||||||
There might be cases when the tabular output of a program is way too
|
There might be cases when the tabular output of a program is way too
|
||||||
large for your current terminal but you still need to see every
|
large for your current terminal but you still need to see every
|
||||||
column. In such cases the \fB\-o extended\fR or \fB\-X\fR option can be
|
column. In such cases the \fB\-o extended\fR or \fB\-X\fR option can be
|
||||||
usefull which enables \fIextended mode\fR. In this mode, each row will be
|
useful which enables \fIextended mode\fR. In this mode, each row will be
|
||||||
printed vertically, header left, value right, aligned by the field
|
printed vertically, header left, value right, aligned by the field
|
||||||
widths. Here's an example:
|
widths. Here's an example:
|
||||||
.PP
|
.PP
|
||||||
|
|||||||
10
tablizer.pod
10
tablizer.pod
@@ -39,8 +39,8 @@ not easy to process.
|
|||||||
|
|
||||||
You can use B<tablizer> to do these and more things.
|
You can use B<tablizer> to do these and more things.
|
||||||
|
|
||||||
B<tablizer> analyses the header fiels of a table, registers the column
|
B<tablizer> analyses the header fields of a table, registers the
|
||||||
positions of each header field and separates columns by those
|
column positions of each header field and separates columns by those
|
||||||
positions.
|
positions.
|
||||||
|
|
||||||
Without any options it reads its input from C<STDIN>, but you can also
|
Without any options it reads its input from C<STDIN>, but you can also
|
||||||
@@ -84,7 +84,7 @@ data (as in GNU sort(1)). The default sort column is the first one. To
|
|||||||
disable sorting at all, supply 0 (Zero) to -k.
|
disable sorting at all, supply 0 (Zero) to -k.
|
||||||
|
|
||||||
Finally the B<-d> option enables debugging output which is mostly
|
Finally the B<-d> option enables debugging output which is mostly
|
||||||
usefull for the developer.
|
useful for the developer.
|
||||||
|
|
||||||
=head2 PATTERNS
|
=head2 PATTERNS
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ C<i> ignore case
|
|||||||
C<m> multiline mode
|
C<m> multiline mode
|
||||||
C<s> single line mode
|
C<s> single line mode
|
||||||
|
|
||||||
Example for a case insensitve search:
|
Example for a case insensitive search:
|
||||||
|
|
||||||
kubectl get pods -A | tablizer "(?i)account"
|
kubectl get pods -A | tablizer "(?i)account"
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ Example for a case insensitve search:
|
|||||||
There might be cases when the tabular output of a program is way too
|
There might be cases when the tabular output of a program is way too
|
||||||
large for your current terminal but you still need to see every
|
large for your current terminal but you still need to see every
|
||||||
column. In such cases the B<-o extended> or B<-X> option can be
|
column. In such cases the B<-o extended> or B<-X> option can be
|
||||||
usefull which enables I<extended mode>. In this mode, each row will be
|
useful which enables I<extended mode>. In this mode, each row will be
|
||||||
printed vertically, header left, value right, aligned by the field
|
printed vertically, header left, value right, aligned by the field
|
||||||
widths. Here's an example:
|
widths. Here's an example:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user