| 125 | } |
| 126 | |
| 127 | func newTodoAddCommand() *todoAddCommand { |
| 128 | todoAddCommand := &todoAddCommand{} |
| 129 | todoAddCommand.cmd = &cobra.Command{ |
| 130 | Use: "add [title]", |
| 131 | Short: "Create a new todo", |
| 132 | Example: ` hey todo add "Buy groceries" |
| 133 | hey todo add -t "Meeting prep" --date 2024-01-20 |
| 134 | hey todo add --title "Review PR" --json |
| 135 | echo "Buy milk" | hey todo add`, |
| 136 | RunE: todoAddCommand.run, |
| 137 | Args: cobra.MaximumNArgs(1), |
| 138 | } |
| 139 | |
| 140 | todoAddCommand.cmd.Flags().StringVarP(&todoAddCommand.title, "title", "t", "", "Todo title") |
| 141 | todoAddCommand.cmd.Flags().StringVar(&todoAddCommand.date, "date", "", "Due date (YYYY-MM-DD)") |
| 142 | |
| 143 | return todoAddCommand |
| 144 | } |
| 145 | |
| 146 | func (c *todoAddCommand) run(cmd *cobra.Command, args []string) error { |
| 147 | if err := requireAuth(); err != nil { |