Commit
+14 -2 +/-1 browse
1 | diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go |
2 | index 8540c48..6256d79 100644 |
3 | --- a/pkg/cmd/cmd.go |
4 | +++ b/pkg/cmd/cmd.go |
5 | @@ -257,16 +257,28 @@ pomo delete 5 10 20 |
6 | func _status(config *pomo.Config) func(*cli.Cmd) { |
7 | return func(cmd *cli.Cmd) { |
8 | cmd.Spec = "[OPTIONS]" |
9 | + var asJSON = cmd.BoolOpt("json", false, "output task history as JSON") |
10 | cmd.Action = func() { |
11 | client, err := pomo.NewClient(config.SocketPath) |
12 | if err != nil { |
13 | - fmt.Println(pomo.FormatStatus(pomo.Status{})) |
14 | + if *asJSON { |
15 | + maybe(json.NewEncoder(os.Stdout).Encode(pomo.Status{})) |
16 | + } else { |
17 | + fmt.Println(pomo.FormatStatus(pomo.Status{})) |
18 | + } |
19 | return |
20 | } |
21 | defer client.Close() |
22 | status, err := client.Status() |
23 | maybe(err) |
24 | - fmt.Println(pomo.FormatStatus(*status)) |
25 | + |
26 | + if *asJSON { |
27 | + |
28 | + maybe(json.NewEncoder(os.Stdout).Encode(status)) |
29 | + |
30 | + } else { |
31 | + fmt.Println(pomo.FormatStatus(*status)) |
32 | + } |
33 | } |
34 | } |
35 | } |