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:
parent
143bac35a8
commit
b149b09905
4
moar.1
4
moar.1
@ -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
|
||||
|
8
moar.go
8
moar.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user