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

Method run

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

Source from the content-addressed store, hash-verified

54}
55
56func (c *habitCompleteCommand) run(cmd *cobra.Command, args []string) error {
57 if err := requireAuth(); err != nil {
58 return err
59 }
60
61 id, err := strconv.ParseInt(args[0], 10, 64)
62 if err != nil {
63 return output.ErrUsage(fmt.Sprintf("invalid habit ID: %s", args[0]))
64 }
65
66 date := c.date
67 if date == "" {
68 date = time.Now().Format("2006-01-02")
69 }
70
71 ctx := cmd.Context()
72 result, err := sdk.Habits().Complete(ctx, date, id)
73 if err != nil {
74 return convertSDKError(err)
75 }
76
77 if writer.IsStyled() {
78 fmt.Fprintf(cmd.OutOrStdout(), "Habit %s completed for %s.%s\n", args[0], date, extractMutationInfoFromResult(result))
79 return nil
80 }
81
82 normalized, nerr := normalizeAny(result)
83 if nerr != nil {
84 return writeOK(nil, output.WithSummary(fmt.Sprintf("Habit %s completed for %s", args[0], date)))
85 }
86 return writeOK(normalized, output.WithSummary(fmt.Sprintf("Habit %s completed for %s", args[0], date)))
87}
88
89// uncomplete
90

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