Skip to content

Commit

Permalink
add filter delete command
Browse files Browse the repository at this point in the history
  • Loading branch information
kobtea committed Mar 6, 2017
1 parent ea1f4d8 commit b851d7b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cmd/todoist/cmd/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,29 @@ var filterUpdateCmd = &cobra.Command{
},
}

var filterDeleteCmd = &cobra.Command{
Use: "delete id [...]",
Short: "delete filters",
RunE: func(cmd *cobra.Command, args []string) error {
if err := util.AutoCommit(func(client todoist.Client, ctx context.Context) error {
return util.ProcessIDs(
args,
func(ids []todoist.ID) error {
for _, id := range ids {
if err := client.Filter.Delete(id); err != nil {
return err
}
}
return nil
})
}); err != nil {
return err
}
fmt.Println("Successful deleting of filter(s).")
return nil
},
}

func init() {
RootCmd.AddCommand(filterCmd)
filterCmd.AddCommand(filterListCmd)
Expand All @@ -150,4 +173,5 @@ func init() {
filterUpdateCmd.Flags().StringP("query", "q", "", "query")
filterUpdateCmd.Flags().StringP("color", "c", "", "color")
filterCmd.AddCommand(filterUpdateCmd)
filterCmd.AddCommand(filterDeleteCmd)
}

0 comments on commit b851d7b

Please sign in to comment.