Skip to content

Commit

Permalink
Don't reformat JSON files by default
Browse files Browse the repository at this point in the history
Fixes: #253
  • Loading branch information
walles committed Nov 2, 2024
1 parent 13de468 commit 07be8d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion moar.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions moar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit 07be8d8

Please sign in to comment.