From 6f093ff69c83526279b9f039aca079162c2b68d5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 5 Feb 2021 09:32:52 +0000 Subject: refactor --- internal/lcontext/lcontext.go | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 internal/lcontext/lcontext.go (limited to 'internal/lcontext') diff --git a/internal/lcontext/lcontext.go b/internal/lcontext/lcontext.go new file mode 100644 index 0000000..bd51d94 --- /dev/null +++ b/internal/lcontext/lcontext.go @@ -0,0 +1,8 @@ +package lcontext + +// LContext stands for line context and is here to help filtering out only specific lines. +type LContext struct { + AfterContext int + BeforeContext int + MaxCount int +} -- cgit v1.2.3 From 2b47630c2f68794a95d5065a7989d489990f7a19 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 23 Mar 2021 09:37:02 +0000 Subject: context aware grep with -max -after and -before not work --- internal/lcontext/lcontext.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'internal/lcontext') diff --git a/internal/lcontext/lcontext.go b/internal/lcontext/lcontext.go index bd51d94..89cb7c3 100644 --- a/internal/lcontext/lcontext.go +++ b/internal/lcontext/lcontext.go @@ -6,3 +6,17 @@ type LContext struct { BeforeContext int MaxCount int } + +// Has returns true if it has any parameter set. +func (c LContext) Has() bool { + if c.AfterContext > 0 { + return true + } + if c.BeforeContext > 0 { + return true + } + if c.MaxCount > 0 { + return true + } + return false +} -- cgit v1.2.3