Fix the JSON beautifier flag

This commit is contained in:
Dan Sosedoff 2017-09-16 21:57:04 -05:00
parent 3c515fcef3
commit 26ea9fc1b8
2 changed files with 25 additions and 24 deletions

View File

@ -112,11 +112,12 @@ func (res *Result) CSV() []byte {
func (res *Result) JSON() []byte {
var data []byte
if command.Opts.EnablePrettyJson {
data, _ = json.MarshalIndent(res.Format(), "", " ")
} else {
if command.Opts.DisablePrettyJson {
data, _ = json.Marshal(res.Format())
} else {
data, _ = json.MarshalIndent(res.Format(), "", " ")
}
return data
}

View File

@ -28,7 +28,7 @@ type Options struct {
LockSession bool `long:"lock-session" description:"Lock session to a single database connection" default:"false"`
Bookmark string `short:"b" long:"bookmark" description:"Bookmark to use for connection. Bookmark files are stored under $HOME/.pgweb/bookmarks/*.toml" default:""`
BookmarksDir string `long:"bookmarks-dir" description:"Overrides default directory for bookmark files to search" default:""`
EnablePrettyJson bool `long:"feature-pretty-json" description:"Format JSON output" default:"true"`
DisablePrettyJson bool `long:"no-pretty-json" description:"Disable JSON formatting feature for result export" default:"false"`
}
var Opts Options