Skip to content

Commit

Permalink
Refactor highlighting group flags
Browse files Browse the repository at this point in the history
- Simplify enable/disable highlighting flags
- Update shell completions for new flag syntax
- Adjust documentation to reflect new flag usage
  • Loading branch information
bensadeh committed Oct 12, 2024
1 parent ad3b437 commit 557a6cb
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 69 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="assets/tailspin.png" width="230"/>
</p>

#
#

<p align="center">
A log file highlighter
Expand Down Expand Up @@ -400,12 +400,8 @@ To clear the filter, use <kbd>&</kbd> with no pattern.
--config-path [PATH] Use the configuration file from the provided path
--words-[COLOR] [WORDS] Highlight the provided words with the given color
--no-builtin-keywords Disable the highlighting of booleans, nulls, log severities and common REST verbs
# Note: The following flags can be used to enable or disable the highlighting of specific groups.
# Enabling one or more groups will disable all other groups. Conversely, disabling one or more
# groups will enable all other groups. Cannot simultaneously enable and disable groups.
--enable-[numbers|dates|urls|ip-addresses|uuids|quotes|paths|processes|key-value-pairs|pointers]
--disable-[numbers|dates|urls|ip-addresses|uuids|quotes|paths|processes|key-value-pairs|pointers]
--enable=[HIGHLIGHT_GROUP] Enable one or more highlight groups, disabling the rest
--disable=[HIGHLIGHT_GROUP] Disable one or more highlight groups, enabling the rest
```


10 changes: 9 additions & 1 deletion completions/tspin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _tspin() {

case "${cmd}" in
tspin)
opts="-f -e -p -c -h -V --follow --start-at-end --print --config-path --listen-command --words-red --words-green --words-yellow --words-blue --words-magenta --words-cyan --enable-numbers --enable-dates --enable-urls --enable-paths --enable-quotes --enable-key-value-pairs --enable-uuids --enable-ip-addresses --enable-pointers --enable-processes --enable-json --disable-numbers --disable-dates --disable-urls --disable-paths --disable-quotes --disable-key-value-pairs --disable-uuids --disable-ip-addresses --disable-pointers --disable-processes --disable-json --no-builtin-keywords --suppress-output --hidden-generate-shell-completions --help --version [FILE]"
opts="-f -e -p -c -h -V --follow --start-at-end --print --config-path --listen-command --words-red --words-green --words-yellow --words-blue --words-magenta --words-cyan --enable --disable --no-builtin-keywords --suppress-output --hidden-generate-shell-completions --help --version [FILE]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down Expand Up @@ -61,6 +61,14 @@ _tspin() {
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--enable)
COMPREPLY=($(compgen -W "numbers urls pointers dates paths quotes key-value-pairs uuids ip-addresses processes json" -- "${cur}"))
return 0
;;
--disable)
COMPREPLY=($(compgen -W "numbers urls pointers dates paths quotes key-value-pairs uuids ip-addresses processes json" -- "${cur}"))
return 0
;;
--hidden-generate-shell-completions)
COMPREPLY=($(compgen -f "${cur}"))
return 0
Expand Down
24 changes: 2 additions & 22 deletions completions/tspin.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,12 @@ complete -c tspin -l words-yellow -d 'Highlight the provided words in yellow' -r
complete -c tspin -l words-blue -d 'Highlight the provided words in blue' -r
complete -c tspin -l words-magenta -d 'Highlight the provided words in magenta' -r
complete -c tspin -l words-cyan -d 'Highlight the provided words in cyan' -r
complete -c tspin -l enable -d 'Enable specific highlighters' -r -f -a "{numbers\t'',urls\t'',pointers\t'',dates\t'',paths\t'',quotes\t'',key-value-pairs\t'',uuids\t'',ip-addresses\t'',processes\t'',json\t''}"
complete -c tspin -l disable -d 'Disable specific highlighters' -r -f -a "{numbers\t'',urls\t'',pointers\t'',dates\t'',paths\t'',quotes\t'',key-value-pairs\t'',uuids\t'',ip-addresses\t'',processes\t'',json\t''}"
complete -c tspin -l hidden-generate-shell-completions -d 'Print completions to stdout' -r
complete -c tspin -s f -l follow -d 'Follow the contents of a file'
complete -c tspin -s e -l start-at-end -d 'Start at the end of the file'
complete -c tspin -s p -l print -d 'Print the output to stdout'
complete -c tspin -l enable-numbers -d 'Enable the highlighting of numbers'
complete -c tspin -l enable-dates -d 'Enable the highlighting of dates'
complete -c tspin -l enable-urls -d 'Enable the highlighting of URLs'
complete -c tspin -l enable-paths -d 'Enable the highlighting of paths'
complete -c tspin -l enable-quotes -d 'Enable the highlighting of quotes'
complete -c tspin -l enable-key-value-pairs -d 'Enable the highlighting of key value pairs'
complete -c tspin -l enable-uuids -d 'Enable the highlighting of UUIDs'
complete -c tspin -l enable-ip-addresses -d 'Enable the highlighting of IP addresses'
complete -c tspin -l enable-pointers -d 'Enable the highlighting of pointers'
complete -c tspin -l enable-processes -d 'Enable the highlighting of unix processes'
complete -c tspin -l enable-json -d 'Enable the highlighting of JSON'
complete -c tspin -l disable-numbers -d 'Disable the highlighting of numbers'
complete -c tspin -l disable-dates -d 'Disable the highlighting of dates'
complete -c tspin -l disable-urls -d 'Disable the highlighting of URLs'
complete -c tspin -l disable-paths -d 'Disable the highlighting of paths'
complete -c tspin -l disable-quotes -d 'Disable the highlighting of quotes'
complete -c tspin -l disable-key-value-pairs -d 'Disable the highlighting of key value pairs'
complete -c tspin -l disable-uuids -d 'Disable the highlighting of UUIDs'
complete -c tspin -l disable-ip-addresses -d 'Disable the highlighting of IP addresses'
complete -c tspin -l disable-pointers -d 'Disable the highlighting of pointers'
complete -c tspin -l disable-processes -d 'Disable the highlighting of unix processes'
complete -c tspin -l disable-json -d 'Disable the highlighting of JSON'
complete -c tspin -l no-builtin-keywords -d 'Disable the highlighting of all builtin keyword groups (booleans, nulls, log severities and common REST verbs)'
complete -c tspin -l suppress-output -d 'Suppress all output (for debugging and benchmarking)'
complete -c tspin -s h -l help -d 'Print help'
Expand Down
24 changes: 2 additions & 22 deletions completions/tspin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,15 @@ _tspin() {
'*--words-blue=[Highlight the provided words in blue]:WORDS_BLUE: ' \
'*--words-magenta=[Highlight the provided words in magenta]:WORDS_MAGENTA: ' \
'*--words-cyan=[Highlight the provided words in cyan]:WORDS_CYAN: ' \
'*--enable=[Enable specific highlighters]:ENABLE:(numbers urls pointers dates paths quotes key-value-pairs uuids ip-addresses processes json)' \
'*--disable=[Disable specific highlighters]:DISABLE:(numbers urls pointers dates paths quotes key-value-pairs uuids ip-addresses processes json)' \
'--hidden-generate-shell-completions=[Print completions to stdout]:GENERATE_SHELL_COMPLETIONS: ' \
'-f[Follow the contents of a file]' \
'--follow[Follow the contents of a file]' \
'-e[Start at the end of the file]' \
'--start-at-end[Start at the end of the file]' \
'-p[Print the output to stdout]' \
'--print[Print the output to stdout]' \
'--enable-numbers[Enable the highlighting of numbers]' \
'--enable-dates[Enable the highlighting of dates]' \
'--enable-urls[Enable the highlighting of URLs]' \
'--enable-paths[Enable the highlighting of paths]' \
'--enable-quotes[Enable the highlighting of quotes]' \
'--enable-key-value-pairs[Enable the highlighting of key value pairs]' \
'--enable-uuids[Enable the highlighting of UUIDs]' \
'--enable-ip-addresses[Enable the highlighting of IP addresses]' \
'--enable-pointers[Enable the highlighting of pointers]' \
'--enable-processes[Enable the highlighting of unix processes]' \
'--enable-json[Enable the highlighting of JSON]' \
'--disable-numbers[Disable the highlighting of numbers]' \
'--disable-dates[Disable the highlighting of dates]' \
'--disable-urls[Disable the highlighting of URLs]' \
'--disable-paths[Disable the highlighting of paths]' \
'--disable-quotes[Disable the highlighting of quotes]' \
'--disable-key-value-pairs[Disable the highlighting of key value pairs]' \
'--disable-uuids[Disable the highlighting of UUIDs]' \
'--disable-ip-addresses[Disable the highlighting of IP addresses]' \
'--disable-pointers[Disable the highlighting of pointers]' \
'--disable-processes[Disable the highlighting of unix processes]' \
'--disable-json[Disable the highlighting of JSON]' \
'--no-builtin-keywords[Disable the highlighting of all builtin keyword groups (booleans, nulls, log severities and common REST verbs)]' \
'--suppress-output[Suppress all output (for debugging and benchmarking)]' \
'-h[Print help]' \
Expand Down
16 changes: 8 additions & 8 deletions man/tspin.1
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ The command traps the interrupt signal to allow for cancelling and resuming foll
Highlight the provided comma separated words in the desired color.
.RE
.sp
\fB\-\-enable\-[numbers|dates|urls|ip\-addresses|uuids|quotes|paths|processes|key\-value\-pairs|pointers]\fP
\fB\-\-enable=[HIGHLIGHT_GROUP]\fP
.RS 4
Enable the highlighting of specific groups only.
If one or more groups are enabled, all other groups are disabled.
Cannot be used with \fI\-\-disable\-[group]\fP.
Disable all highlighting groups except the ones specified.
Comma separated list of groups.
Cannot be used with \fI\-\-disable=[HIGHLIGHT_GROUP]\fP.
.RE
.sp
\fB\-\-disable\-[numbers|dates|urls|ip\-addresses|uuids|quotes|paths|processes|key\-value\-pairs|pointers]\fP
\fB\-\-disable=[HIGHLIGHT_GROUP]\fP
.RS 4
Disable the highlighting of specific groups.
By default, all groups are enabled.
Cannot be used with \fI\-\-enable\-[group]\fP.
Disable the specified highlighting groups.
Comma separated list of groups.
Cannot be used with \fI\-\-enable=[HIGHLIGHT_GROUP]\fP.
.RE
.sp
\fB\-\-no\-builtin\-keywords\fP
Expand Down
18 changes: 9 additions & 9 deletions util/tspin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ The command traps the interrupt signal to allow for cancelling and resuming foll
*--words-[red|green|yellow|blue|magenta|cyan]*::
Highlight the provided comma separated words in the desired color.

*--enable-[numbers|dates|urls|ip-addresses|uuids|quotes|paths|processes|key-value-pairs|pointers]*::
Enable the highlighting of specific groups only.
If one or more groups are enabled, all other groups are disabled.
Cannot be used with _--disable-[group]_.

*--disable-[numbers|dates|urls|ip-addresses|uuids|quotes|paths|processes|key-value-pairs|pointers]*::
Disable the highlighting of specific groups.
By default, all groups are enabled.
Cannot be used with _--enable-[group]_.
*--enable=[HIGHLIGHT_GROUP]*::
Disable all highlighting groups except the ones specified.
Comma separated list of groups.
Cannot be used with _--disable=[HIGHLIGHT_GROUP]_.

*--disable=[HIGHLIGHT_GROUP]*::
Disable the specified highlighting groups.
Comma separated list of groups.
Cannot be used with _--enable=[HIGHLIGHT_GROUP]_.

*--no-builtin-keywords*::
Disables the highlighting of all builtin keyword groups (booleans, severity and REST).
Expand Down

0 comments on commit 557a6cb

Please sign in to comment.