From 07be8d81706bb81505ba4eece6b747e8992e5265 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Sat, 2 Nov 2024 15:45:14 +0100 Subject: [PATCH] Don't reformat JSON files by default Fixes: https://github.com/walles/moar/issues/253 --- moar.1 | 5 ++++- moar.go | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/moar.1 b/moar.1 index 3e49504..2b55d68 100644 --- a/moar.1 +++ b/moar.1 @@ -63,7 +63,7 @@ Retain screen contents when exiting moar Hide line numbers on startup, press left arrow key to show .TP \fB\-\-no\-reformat\fR -Moar will implicitly reformat some input (like JSON). This switch disables that reformatting. Even with this switch, highlighting is still done. +No effect, exists for backwards compatibility. See --reformat. .TP \fB\-\-no\-statusbar\fR Hide the status bar, toggle with @@ -72,6 +72,9 @@ Hide the status bar, toggle with \fB\-\-quit\-if\-one\-screen\fR Print input contents without paging if the input fits on one screen .TP +\fB\-\-reformat\fR +Reformat supported input files (JSON) before showing them. +.TP \fB\-\-render\-unprintable\fR={\fBhighlight\fR | \fBwhitespace\fR} How unprintable characters are rendered .TP diff --git a/moar.go b/moar.go index 7cb97b6..cb4ab1a 100644 --- a/moar.go +++ b/moar.go @@ -331,7 +331,8 @@ func pagerFromArgs( noLineNumbers := flagSet.Bool("no-linenumbers", noLineNumbersDefault(), "Hide line numbers on startup, press left arrow key to show") noStatusBar := flagSet.Bool("no-statusbar", false, "Hide the status bar, toggle with '='") - noReFormat := flagSet.Bool("no-reformat", false, "Never reformat the input (but keep highlighting)") + reFormat := flagSet.Bool("reformat", false, "Reformat some input files (JSON)") + flagSet.Bool("no-reformat", true, "No effect, kept for compatibility. See --reforamat") quitIfOneScreen := flagSet.Bool("quit-if-one-screen", false, "Don't page if contents fits on one screen") noClearOnExit := flagSet.Bool("no-clear-on-exit", false, "Retain screen contents when exiting moar") statusBarStyle := flagSetFunc(flagSet, "statusbar", m.STATUSBAR_STYLE_INVERSE, @@ -461,7 +462,7 @@ func pagerFromArgs( } var reader *m.Reader - shouldFormat := !*noReFormat + shouldFormat := *reFormat if stdinIsRedirected { // Display input pipe contents reader = m.NewReaderFromStream("", os.Stdin, formatter, m.ReaderOptions{Lexer: *lexer, ShouldFormat: shouldFormat})