From 34e2b8d85541f9c550a80b92cf1fdf089a930a1b Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Thu, 6 Oct 2022 20:02:40 +0200 Subject: [PATCH] fixed issuer #4, version string missing, and added some docs about pattern syntax --- Makefile | 2 +- cmd/tablizer.go | 32 ++++++++++++++++++++++++++++---- tablizer.1 | 42 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index f106b40..42a5377 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ GID = 0 BRANCH = $(shell git describe --all | cut -d/ -f2) COMMIT = $(shell git rev-parse --short=8 HEAD) BUILD = $(shell date +%Y.%m.%d.%H%M%S) -VERSION:= $(if $(filter $(BRANCH), development),$(version)-$(BRANCH)-$(COMMIT)-$(BUILD)) +VERSION:= $(if $(filter $(BRANCH), development),$(version)-$(BRANCH)-$(COMMIT)-$(BUILD),$(version)) all: $(tool).1 cmd/$(tool).go buildlocal diff --git a/cmd/tablizer.go b/cmd/tablizer.go index b5d091e..3e79bde 100644 --- a/cmd/tablizer.go +++ b/cmd/tablizer.go @@ -24,10 +24,10 @@ SYNOPSIS DESCRIPTION Many programs generate tabular output. But sometimes you need to post-process these tables, you may need to remove one or more columns or - you may want to filter for some pattern or you may need the output in - another program and need to parse it somehow. Standard unix tools such - as awk(1), grep(1) or column(1) may help, but sometimes it's a tedious - business. + you may want to filter for some pattern (See PATTERNS) or you may need + the output in another program and need to parse it somehow. Standard + unix tools such as awk(1), grep(1) or column(1) may help, but sometimes + it's a tedious business. Let's take the output of the tool kubectl. It contains cells with withespace and they do not separate columns by TAB characters. This is @@ -73,6 +73,30 @@ DESCRIPTION Finally the -d option enables debugging output which is mostly usefull for the developer. + PATTERNS + You can reduce the rows being displayed by using a regular expression + pattern. The regexp is PCRE compatible, refer to the syntax cheat sheet + here: . If you want to read a + more comprehensive documentation about the topic and have perl installed + you can read it with: + + perldoc perlre + + Or read it online: . + + A note on modifiers: the regexp engine used in tablizer uses another + modifier syntax: + + (?MODIFIER) + + The most important modifiers are: + + "i" ignore case "m" multiline mode "s" single line mode + + Example for a case insensitve search: + + kubectl get pods -A | tablizer "(?i)account" + OUTPUT MODES 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. diff --git a/tablizer.1 b/tablizer.1 index 78fab95..c028cd4 100644 --- a/tablizer.1 +++ b/tablizer.1 @@ -162,12 +162,12 @@ tablizer \- Manipulate tabular output of other programs .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" -Many programs generate tabular output. But sometimes you need to +Many programs generate tabular output. But sometimes you need to post-process these tables, you may need to remove one or more columns -or you may want to filter for some pattern or you may need the output -in another program and need to parse it somehow. Standard unix tools -such as \fBawk\fR\|(1), \fBgrep\fR\|(1) or \fBcolumn\fR\|(1) may help, but sometimes it's a -tedious business. +or you may want to filter for some pattern (See \s-1PATTERNS\s0) or you +may need the output in another program and need to parse it somehow. +Standard unix tools such as \fBawk\fR\|(1), \fBgrep\fR\|(1) or \fBcolumn\fR\|(1) may help, but +sometimes it's a tedious business. .PP Let's take the output of the tool kubectl. It contains cells with withespace and they do not separate columns by \s-1TAB\s0 characters. This is @@ -220,6 +220,38 @@ The numbering can be suppressed by using the \fB\-n\fR option. .PP Finally the \fB\-d\fR option enables debugging output which is mostly usefull for the developer. +.SS "\s-1PATTERNS\s0" +.IX Subsection "PATTERNS" +You can reduce the rows being displayed by using a regular expression +pattern. The regexp is \s-1PCRE\s0 compatible, refer to the syntax cheat +sheet here: . If you want +to read a more comprehensive documentation about the topic and have +perl installed you can read it with: +.PP +.Vb 1 +\& perldoc perlre +.Ve +.PP +Or read it online: . +.PP +A note on modifiers: the regexp engine used in tablizer uses another +modifier syntax: +.PP +.Vb 1 +\& (?MODIFIER) +.Ve +.PP +The most important modifiers are: +.PP +\&\f(CW\*(C`i\*(C'\fR ignore case +\&\f(CW\*(C`m\*(C'\fR multiline mode +\&\f(CW\*(C`s\*(C'\fR single line mode +.PP +Example for a case insensitve search: +.PP +.Vb 1 +\& kubectl get pods \-A | tablizer "(?i)account" +.Ve .SS "\s-1OUTPUT MODES\s0" .IX Subsection "OUTPUT MODES" There might be cases when the tabular output of a program is way too