Allow pomo status --json
This commit is contained in:
parent
c7cdf725ab
commit
c6c3e43991
|
@ -257,19 +257,31 @@ pomo delete 5 10 20
|
|||
func _status(config *pomo.Config) func(*cli.Cmd) {
|
||||
return func(cmd *cli.Cmd) {
|
||||
cmd.Spec = "[OPTIONS]"
|
||||
var asJSON = cmd.BoolOpt("json", false, "output task history as JSON")
|
||||
cmd.Action = func() {
|
||||
client, err := pomo.NewClient(config.SocketPath)
|
||||
if err != nil {
|
||||
if *asJSON {
|
||||
maybe(json.NewEncoder(os.Stdout).Encode(pomo.Status{}))
|
||||
} else {
|
||||
fmt.Println(pomo.FormatStatus(pomo.Status{}))
|
||||
}
|
||||
return
|
||||
}
|
||||
defer client.Close()
|
||||
status, err := client.Status()
|
||||
maybe(err)
|
||||
|
||||
if *asJSON {
|
||||
|
||||
maybe(json.NewEncoder(os.Stdout).Encode(status))
|
||||
|
||||
} else {
|
||||
fmt.Println(pomo.FormatStatus(*status))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func _config(config *pomo.Config) func(*cli.Cmd) {
|
||||
return func(cmd *cli.Cmd) {
|
||||
|
|
Loading…
Reference in New Issue