MCPcopy Create free account
hub / github.com/basecamp/hey-cli / run

Method run

internal/cmd/habit.go:112–143  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

110}
111
112func (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}

Callers

nothing calls this directly

Calls 7

WithSummaryFunction · 0.92
requireAuthFunction · 0.85
convertSDKErrorFunction · 0.85
normalizeAnyFunction · 0.85
writeOKFunction · 0.85
IsStyledMethod · 0.80

Tested by

no test coverage detected