(cmd *cobra.Command, args []string)
| 147 | return writeMutation(cmd, summary, nil) |
| 148 | } |
| 149 | |
| 150 | // current |
| 151 | |
| 152 | type timetrackCurrentCommand struct { |
| 153 | cmd *cobra.Command |
| 154 | } |
| 155 | |
| 156 | func newTimetrackCurrentCommand() *timetrackCurrentCommand { |
| 157 | timetrackCurrentCommand := &timetrackCurrentCommand{} |
| 158 | timetrackCurrentCommand.cmd = &cobra.Command{ |
| 159 | Use: "current", |
| 160 | Short: "Show current time tracking status", |
| 161 | Example: ` hey timetrack current |
| 162 | hey timetrack current --json`, |
| 163 | RunE: timetrackCurrentCommand.run, |
| 164 | } |
| 165 | |
| 166 | return timetrackCurrentCommand |
| 167 | } |
| 168 | |
| 169 | func (c *timetrackCurrentCommand) run(cmd *cobra.Command, args []string) error { |
| 170 | if err := requireAuth(); err != nil { |
| 171 | return err |
| 172 | } |
| 173 | |
| 174 | ctx := cmd.Context() |
| 175 | track, err := sdk.TimeTracks().GetOngoing(ctx) |
| 176 | if err != nil { |
| 177 | return apierr.FromSDK(err) |
| 178 | } |
| 179 | |
| 180 | if writer.IsStyled() { |
| 181 | w := cmd.OutOrStdout() |
| 182 | if track == nil { |
| 183 | fmt.Fprintln(w, "No active time track.") |
| 184 | return nil |
| 185 | } |
nothing calls this directly
no test coverage detected