Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion jp.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func main() {
Value: "auto",
Usage: "Change the color setting (none, auto, always). auto is based on whether output is a tty.",
},
cli.BoolFlag{
Name: "compact",
Usage: "Produce compact JSON output that omits nonessential whitespace.",
},
cli.BoolFlag{
Name: "unquoted, u",
Usage: "If the final result is a string, it will be printed without quotes.",
Expand Down Expand Up @@ -153,7 +157,9 @@ func runMain(c *cli.Context) int {
} else {
var toJSON []byte
var err error
if color.NoColor {
if c.Bool("compact") {
toJSON, err = json.Marshal(result)
} else if color.NoColor {
// avoid doing the extra processing in jsoncolor
toJSON, err = json.MarshalIndent(result, "", " ")
} else {
Expand Down