Skip to content

Commit

Permalink
Add --follow command line parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
walles committed Nov 28, 2022
1 parent 143bac3 commit b149b09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions moar.1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Size of color palette we output to the terminal
Print debug logs after exiting, less verbose than
.B \-\-trace
.TP
\fB\-\-follow\fR
Scrolls automatically to follow piped input, just like
.B tail \-f
.TP
\fB\-\-no\-clear\-on\-exit\fR
Retain screen contents when exiting moar
.TP
Expand Down
8 changes: 5 additions & 3 deletions moar.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func main() {
debug := flagSet.Bool("debug", false, "Print debug logs after exiting")
trace := flagSet.Bool("trace", false, "Print trace logs after exiting")
wrap := flagSet.Bool("wrap", false, "Wrap long lines")
follow := flagSet.Bool("follow", false, "Follow piped input just like \"tail -f\"")
styleOption := flagSet.String("style", "native",
"Highlighting style from https://xyproto.github.io/splash/docs/longer/all.html")
colorsOption := flagSet.String("colors", "auto", "Highlighting palette size: 8, 16, 256, 16M, auto")
Expand Down Expand Up @@ -371,7 +372,7 @@ func main() {
// Display input pipe contents
reader := m.NewReaderFromStream("", os.Stdin)
startPaging(reader,
*wrap, *noLineNumbers, *noStatusBar, *noClearOnExit, statusBarStyle, unprintableStyle,
*wrap, *follow, *noLineNumbers, *noStatusBar, *noClearOnExit, statusBarStyle, unprintableStyle,
scrollLeftHint, scrollRightHint)
return
}
Expand All @@ -383,12 +384,12 @@ func main() {
os.Exit(1)
}
startPaging(reader,
*wrap, *noLineNumbers, *noStatusBar, *noClearOnExit, statusBarStyle, unprintableStyle,
*wrap, *follow, *noLineNumbers, *noStatusBar, *noClearOnExit, statusBarStyle, unprintableStyle,
scrollLeftHint, scrollRightHint)
}

func startPaging(reader *m.Reader,
wrapLongLines, noLineNumbers, noStatusBar, noClearOnExit bool,
wrapLongLines, follow, noLineNumbers, noStatusBar, noClearOnExit bool,
statusBarStyle m.StatusBarStyle,
unprintableStyle m.UnprintableStyle,
scrollLeftHint twin.Cell,
Expand All @@ -403,6 +404,7 @@ func startPaging(reader *m.Reader,
log.SetOutput(&loglines)
pager := m.NewPager(reader)
pager.WrapLongLines = wrapLongLines
pager.Following = follow
pager.ShowLineNumbers = !noLineNumbers
pager.ShowStatusBar = !noStatusBar
pager.StatusBarStyle = statusBarStyle
Expand Down

0 comments on commit b149b09

Please sign in to comment.