From 59b9b13360507d40cd24ded611a95b9a54e79af5 Mon Sep 17 00:00:00 2001 From: kobtea Date: Wed, 22 Feb 2017 01:40:47 +0900 Subject: [PATCH] add item list command --- cmd/todoist/cmd/item.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 cmd/todoist/cmd/item.go diff --git a/cmd/todoist/cmd/item.go b/cmd/todoist/cmd/item.go new file mode 100644 index 0000000..2b90c79 --- /dev/null +++ b/cmd/todoist/cmd/item.go @@ -0,0 +1,34 @@ +package cmd + +import ( + "fmt" + + "github.com/kobtea/go-todoist/cmd/util" + "github.com/spf13/cobra" +) + +// itemCmd represents the item command +var itemCmd = &cobra.Command{ + Use: "item", + Short: "subcommand for item", +} + +var itemListCmd = &cobra.Command{ + Use: "list", + Short: "list items", + RunE: func(cmd *cobra.Command, args []string) error { + client, err := newClient() + if err != nil { + return err + } + items := client.Item.GetAll() + relations := client.Relation.Items(items) + fmt.Println(util.ItemTableString(items, relations)) + return nil + }, +} + +func init() { + RootCmd.AddCommand(itemCmd) + itemCmd.AddCommand(itemListCmd) +}