diff --git a/cmd/sql-main.go b/cmd/sql-main.go index 4654011d..e30462dc 100644 --- a/cmd/sql-main.go +++ b/cmd/sql-main.go @@ -78,7 +78,7 @@ var sqlCmd = cli.Command{ Usage: "run sql queries on objects", Action: mainSQL, Before: setGlobalsFromContext, - Flags: getSQLFlags(), + Flags: append(sqlFlags, globalFlags...), CustomHelpTemplate: `NAME: {{.HelpName}} - {{.Usage}} @@ -123,17 +123,6 @@ EXAMPLES: `, } -// filter json from allowed flags for sql command -func getSQLFlags() []cli.Flag { - flags := append(sqlFlags, ioFlags...) - for _, f := range globalFlags { - if f.GetName() != "json" { - flags = append(flags, f) - } - } - return flags -} - // valid CSV and JSON keys for input/output serialization var ( validCSVCommonKeys = []string{"FieldDelimiter", "QuoteChar", "QuoteEscChar"} @@ -301,7 +290,7 @@ func getOutputSerializationOpts(ctx *cli.Context, csvHdrs []string) (opts map[st m["csv"] = kv } - if jsonType { + if jsonType || globalJSON { kv, err := parseSerializationOpts(ojson, validJSONCSVCommonOutputKeys, validJSONOutputAbbrKeys) fatalIf(err, "Invalid value(s) specified for --json-output flag") m["json"] = kv @@ -433,7 +422,7 @@ func getAndValidateArgs(ctx *cli.Context, encKeyDB map[string][]prefixSSEPair, u // check sql input arguments. func checkSQLSyntax(ctx *cli.Context) { - if !ctx.Args().Present() { + if len(ctx.Args()) == 0 { cli.ShowCommandHelpAndExit(ctx, "sql", 1) // last argument is exit code. } }