Skip to content

Commit

Permalink
Refactor keyword highlighting options and completions
Browse files Browse the repository at this point in the history
  • Loading branch information
bensadeh committed Oct 12, 2024
1 parent cdb0916 commit ed0ec2d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 56 deletions.
17 changes: 10 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 All @@ -19,7 +19,7 @@ A log file highlighter
- 🌈 Highlights numbers, dates, IP-addresses, UUIDs, URLs and more
- ⚙️ All highlight groups are customizable
- 🧬 Easy to integrate with other commands
- 🔍 Uses `less` under the hood
- 🔍 Uses `less` under the hood

#

Expand Down Expand Up @@ -324,7 +324,7 @@ It supports one capture group `()`. When found, it will apply the style to the c

```toml
[[regexps]]
regular_expression = 'Started (.*)\.'
regex = 'Started (.*)\.'
style = { fg = "red" }
```

Expand Down Expand Up @@ -406,10 +406,13 @@ To clear the filter, use <kbd>&</kbd> with no pattern.
-c, --listen-command '[CMD]' Listen the output (stdout) of the provided command
--config-path [PATH] Use the configuration file from the provided path
--words-[COLOR] [WORDS] Highlight the provided words with the given color
--disable-builtin-keywords Disable the highlighting of all builtin groups
--disable-booleans Disable the highlighting of booleans and nulls
--disable-severity Disable the highlighting of severity levels
--disable-rest Disable the highlighting of REST verbs
--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]
```


2 changes: 1 addition & 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 --disable-builtin-keywords --disable-booleans --disable-severity --disable-rest --enable-numbers --enable-dates --enable-urls --enable-paths --enable-quotes --enable-key-value-pairs --enable-uuids --enable-ip-addresses --enable-pointers --enable-processes --disable-numbers --disable-dates --disable-urls --disable-paths --disable-quotes --disable-key-value-pairs --disable-uuids --disable-ip-addresses --disable-pointers --disable-processes --hidden-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-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]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down
9 changes: 4 additions & 5 deletions completions/tspin.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ complete -c tspin -l hidden-generate-shell-completions -d 'Print completions to
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 disable-builtin-keywords -d 'Disable the highlighting of all builtin keyword groups (booleans, severity and REST)'
complete -c tspin -l disable-booleans -d 'Disable the highlighting of booleans and nulls'
complete -c tspin -l disable-severity -d 'Disable the highlighting of severity levels'
complete -c tspin -l disable-rest -d 'Disable the highlighting of REST verbs'
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'
Expand All @@ -24,6 +20,7 @@ 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'
Expand All @@ -34,6 +31,8 @@ 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 hidden-suppress-output -d 'Suppress all output (for debugging and benchmarking)'
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'
complete -c tspin -s V -l version -d 'Print version'
9 changes: 4 additions & 5 deletions completions/tspin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ _tspin() {
'--start-at-end[Start at the end of the file]' \
'-p[Print the output to stdout]' \
'--print[Print the output to stdout]' \
'--disable-builtin-keywords[Disable the highlighting of all builtin keyword groups (booleans, severity and REST)]' \
'--disable-booleans[Disable the highlighting of booleans and nulls]' \
'--disable-severity[Disable the highlighting of severity levels]' \
'--disable-rest[Disable the highlighting of REST verbs]' \
'--enable-numbers[Enable the highlighting of numbers]' \
'--enable-dates[Enable the highlighting of dates]' \
'--enable-urls[Enable the highlighting of URLs]' \
Expand All @@ -45,6 +41,7 @@ _tspin() {
'--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]' \
Expand All @@ -55,7 +52,9 @@ _tspin() {
'--disable-ip-addresses[Disable the highlighting of IP addresses]' \
'--disable-pointers[Disable the highlighting of pointers]' \
'--disable-processes[Disable the highlighting of unix processes]' \
'--hidden-suppress-output[Suppress all output (for debugging and benchmarking)]' \
'--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]' \
'--help[Print help]' \
'-V[Print version]' \
Expand Down
25 changes: 12 additions & 13 deletions man/tspin.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: tspin
.\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.23
.\" Date: 2024-10-06
.\" Date: 2024-10-12
.\" Manual: tailspin
.\" Source: tailspin 4.0.0
.\" Language: English
.\"
.TH "TSPIN" "1" "2024-10-06" "tailspin 4.0.0" "tailspin"
.TH "TSPIN" "1" "2024-10-12" "tailspin 4.0.0" "tailspin"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
Expand Down Expand Up @@ -72,24 +72,23 @@ 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\-\-disable\-builtin\-keywords\fP
\fB\-\-enable\-[numbers|dates|urls|ip\-addresses|uuids|quotes|paths|processes|key\-value\-pairs|pointers]\fP
.RS 4
Disables the highlighting of all builtin keyword groups (booleans, severity and REST).
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.
.RE
.sp
\fB\-\-disable\-booleans\fP
\fB\-\-disable\-[numbers|dates|urls|ip\-addresses|uuids|quotes|paths|processes|key\-value\-pairs|pointers]\fP
.RS 4
Disables the highlighting of booleans and nulls.
Disable the highlighting of specific groups.
By default, all groups are enabled.
Cannot be used with \fI\-\-enable\-[group]\fP.
.RE
.sp
\fB\-\-disable\-severity\fP
\fB\-\-no\-builtin\-keywords\fP
.RS 4
Disables the highlighting of severity levels.
.RE
.sp
\fB\-\-disable\-rest\fP
.RS 4
Disables the highlighting of REST verbs.
Disables the highlighting of all builtin keyword groups (booleans, severity and REST).
.RE
.SH "SEE ALSO"
.sp
Expand Down
16 changes: 0 additions & 16 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,6 @@ pub struct Cli {
#[clap(long = "words-cyan", use_value_delimiter = true)]
pub words_cyan: Vec<String>,

/// Disable the highlighting of all builtin keyword groups (booleans, severity and REST)
#[clap(long = "disable-builtin-keywords")]
pub disable_keyword_builtins: bool,

/// Disable the highlighting of booleans and nulls
#[clap(long = "disable-booleans")]
pub disable_booleans: bool,

/// Disable the highlighting of severity levels
#[clap(long = "disable-severity")]
pub disable_severity: bool,

/// Disable the highlighting of REST verbs
#[clap(long = "disable-rest")]
pub disable_rest: bool,

/// Enable the highlighting of numbers
#[clap(long = "enable-numbers")]
pub enable_numbers: bool,
Expand Down
19 changes: 10 additions & 9 deletions util/tspin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@ 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.

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

*--disable-booleans*::
Disables the highlighting of booleans and nulls.
*--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-severity*::
Disables the highlighting of severity levels.
*--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]_.

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

== SEE ALSO

Expand Down

0 comments on commit ed0ec2d

Please sign in to comment.