add output colorization support using regexes

This commit is contained in:
2026-01-19 13:38:37 +01:00
parent 46fde289f5
commit cb3921458a
8 changed files with 86 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright © 2022-2025 Thomas von Dein
Copyright © 2022-2026 Thomas von Dein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -95,6 +95,7 @@ func Execute() {
conf.PrepareCustomHeaders(headers)
wrapE(conf.PrepareFilters())
wrapE(conf.PrepareColorizers())
conf.DetermineColormode()
conf.ApplyDefaults()
@@ -191,6 +192,8 @@ func Execute() {
"filter", "F", nil, "Filter by field (field=regexp || field!=regexp)")
rootCmd.PersistentFlags().StringArrayVarP(&conf.Transposers,
"regex-transposer", "R", nil, "apply /search/replace/ regexp to fields given in -T")
rootCmd.PersistentFlags().StringArrayVarP(&conf.Colorizers,
"regex-colorizer", "K", nil, "apply /search/color[:background]/ to the whole output")
// input
rootCmd.PersistentFlags().StringVarP(&conf.InputFile, "read-file", "r", "",

View File

@@ -13,6 +13,7 @@ const shortusage = `tablizer [regex,...] [-r file] [flags]
-x col,... use custom headers -d debug
-o char use char as output separator -g auto generate headers
-K /pattern/foreground[:background]/ colorize pattern of output
-O org -C CSV -M md -X ext -S shell -Y yaml -J json -P template
-a sort by age -i sort numerically -t sort by time -D sort descending order
-m show manual -v show version --help show detailed help`