(cmd *cobra.Command, args []string)
| 110 | } |
| 111 | |
| 112 | func (c *habitUncompleteCommand) run(cmd *cobra.Command, args []string) error { |
| 113 | if err := requireAuth(); err != nil { |
| 114 | return err |
| 115 | } |
| 116 | |
| 117 | id, err := strconv.ParseInt(args[0], 10, 64) |
| 118 | if err != nil { |
| 119 | return output.ErrUsage(fmt.Sprintf("invalid habit ID: %s", args[0])) |
| 120 | } |
| 121 | |
| 122 | date := c.date |
| 123 | if date == "" { |
| 124 | date = time.Now().Format("2006-01-02") |
| 125 | } |
| 126 | |
| 127 | ctx := cmd.Context() |
| 128 | result, err := sdk.Habits().Uncomplete(ctx, date, id) |
| 129 | if err != nil { |
| 130 | return convertSDKError(err) |
| 131 | } |
| 132 | |
| 133 | if writer.IsStyled() { |
| 134 | fmt.Fprintf(cmd.OutOrStdout(), "Habit %s uncompleted for %s.%s\n", args[0], date, extractMutationInfoFromResult(result)) |
| 135 | return nil |
| 136 | } |
| 137 | |
| 138 | normalized, nerr := normalizeAny(result) |
| 139 | if nerr != nil { |
| 140 | return writeOK(nil, output.WithSummary(fmt.Sprintf("Habit %s uncompleted for %s", args[0], date))) |
| 141 | } |
| 142 | return writeOK(normalized, output.WithSummary(fmt.Sprintf("Habit %s uncompleted for %s", args[0], date))) |
| 143 | } |
nothing calls this directly
no test coverage detected