(cmd *cobra.Command, args []string)
| 101 | Use: "stop", |
| 102 | Short: "Stop time tracking", |
| 103 | Long: `Stop the running time track. |
| 104 | |
| 105 | --category files the track under a category as it stops it, in the one request, and HEY |
| 106 | creates the category if it has none by that title. There is no clearing a category this |
| 107 | way: a blank title leaves the track filed where it was.`, |
| 108 | Example: ` hey timetrack stop |
| 109 | hey timetrack stop --category "Client work" |
| 110 | hey timetrack stop --json`, |
| 111 | RunE: timetrackStopCommand.run, |
| 112 | } |
| 113 | |
| 114 | timetrackStopCommand.cmd.Flags().StringVar(&timetrackStopCommand.category, "category", "", "Category title to file the stopped track under, created if HEY has none by that title") |
| 115 | |
| 116 | return timetrackStopCommand |
| 117 | } |
| 118 | |
| 119 | func (c *timetrackStopCommand) run(cmd *cobra.Command, args []string) error { |
| 120 | if err := requireAuth(); err != nil { |
| 121 | return err |
| 122 | } |
| 123 | |
| 124 | ctx := cmd.Context() |
| 125 | track, err := sdk.TimeTracks().GetOngoing(ctx) |
| 126 | if err != nil { |
| 127 | return apierr.FromSDK(err) |
| 128 | } |
| 129 | |
| 130 | if track == nil { |
| 131 | return apierr.ErrNotFound("time track", "active") |
nothing calls this directly
no test coverage detected