1
1
mirror of https://github.com/walles/moar.git synced 2024-08-16 23:40:35 +03:00

Add --follow command line parameter

Ref: https://github.com/walles/moar/issues/108#issuecomment-1328724290
This commit is contained in:
Johan Walles 2022-11-28 19:09:17 +01:00
parent 143bac35a8
commit b149b09905
2 changed files with 9 additions and 3 deletions

4
moar.1
View File

@ -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

View File

@ -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")
@ -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
}
@ -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,
@ -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