Skip to content

Commit

Permalink
add item list command
Browse files Browse the repository at this point in the history
  • Loading branch information
kobtea committed Feb 21, 2017
1 parent 76c5b6d commit 59b9b13
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cmd/todoist/cmd/item.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 59b9b13

Please sign in to comment.