From 08937e97bcda8eaee11bfe6804bcecc49597726d Mon Sep 17 00:00:00 2001 From: CuiHaozhi Date: Sat, 18 Feb 2017 23:04:47 +0800 Subject: [PATCH] ps: --format value check Signed-off-by: CuiHaozhi --- ps.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ps.go b/ps.go index 228f161a0..b8a1b111b 100644 --- a/ps.go +++ b/ps.go @@ -20,7 +20,7 @@ var psCommand = cli.Command{ Flags: []cli.Flag{ cli.StringFlag{ Name: "format, f", - Value: "", + Value: "table", Usage: `select one of: ` + formatOptions, }, }, @@ -38,8 +38,12 @@ var psCommand = cli.Command{ return err } - if context.String("format") == "json" { + switch context.String("format") { + case "table": + case "json": return json.NewEncoder(os.Stdout).Encode(pids) + default: + return fmt.Errorf("invalid format option") } // [1:] is to remove command name, ex: