Skip to content

Add timers CLI command to ottoctl#79

Merged
rustyeddy merged 3 commits intomainfrom
copilot/add-cli-command-for-timers
Jan 4, 2026
Merged

Add timers CLI command to ottoctl#79
rustyeddy merged 3 commits intomainfrom
copilot/add-cli-command-for-timers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 4, 2026

Implements a new timers command for the ottoctl CLI to query timer/ticker information from the Otto server's existing /api/timers endpoint.

Changes

  • cmd/ottoctl/cmd_timers.go: New Cobra command following the pattern of stats and stations commands
  • client/client.go: Added GetTimers() method to fetch []utils.TickerInfo from /api/timers
  • cmd/ottoctl/cmd_root.go: Registered timersCmd with root command
  • cmd/ottoctl/cmd_timers_test.go: Test coverage for success, empty response, and error cases
  • cmd/ottoctl/testdata/timers.json: Test fixture data

Usage

# Query timers from server
./ottoctl timers --server http://localhost:8011

# Output (JSON formatted)
[
  {
    "name": "heartbeat",
    "last_tick": "2026-01-04T16:40:00Z",
    "ticks": 120,
    "active": true
  }
]

Additional Fixes

  • cmd/ottoctl/ottoctl/Makefile: Corrected go build flag order (-o before target)
  • .gitignore: Added cmd/ottoctl/ottoctl/ottoctl to exclude binary from version control
Original prompt

This section details on the original issue you should resolve

<issue_title>ottoctl cli Timers</issue_title>
<issue_description>write a cli command for timers.</issue_description>

<agent_instructions>Write a cobra cli command in cmd/ottoctl/cmd_tickers.go as a REST client in client/client.go following the style of other cli commands. The ticker implementation is in utils/tickers.go</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@rustyeddy rustyeddy added the enhancement New feature or request label Jan 4, 2026
@rustyeddy rustyeddy added this to the Refactor CLI milestone Jan 4, 2026
Co-authored-by: rustyeddy <2903425+rustyeddy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CLI command for timers in ottoctl Add timers CLI command to ottoctl Jan 4, 2026
Copilot AI requested a review from rustyeddy January 4, 2026 16:52
@rustyeddy rustyeddy marked this pull request as ready for review January 4, 2026 17:03
Copilot AI review requested due to automatic review settings January 4, 2026 17:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new timers command to the ottoctl CLI tool that queries timer/ticker information from the Otto server's existing /api/timers endpoint, following established patterns from the stats and stations commands.

  • Implements GetTimers() client method to fetch timer information from the server
  • Adds timers command with JSON output formatting
  • Includes comprehensive test coverage for success, empty, and error cases
  • Fixes Makefile flag ordering and adds binary to .gitignore

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cmd/ottoctl/cmd_timers.go New Cobra command implementation for querying timer information from the server
client/client.go Adds GetTimers() method to fetch []utils.TickerInfo from /api/timers endpoint
cmd/ottoctl/cmd_root.go Registers timersCmd with the root command
cmd/ottoctl/cmd_timers_test.go Test coverage for success, empty response, and error scenarios
cmd/ottoctl/testdata/timers.json Test fixture data with sample timer information
cmd/ottoctl/ottoctl/Makefile Corrects go build flag order (-o before target path)
.gitignore Adds cmd/ottoctl/ottoctl/ottoctl binary to exclusion list

// Pretty print the JSON response
jsonBytes, err := json.MarshalIndent(timers, "", " ")
if err != nil {
fmt.Fprintf(errOutput, "%s", err)
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message formatting is inconsistent with the pattern on line 30. The error should include a newline character for consistency. Consider changing fmt.Fprintf(errOutput, "%s", err) to fmt.Fprintf(errOutput, "%v\n", err) or fmt.Fprintf(errOutput, "Error marshaling JSON: %v\n", err) to match the format used on line 30.

Suggested change
fmt.Fprintf(errOutput, "%s", err)
fmt.Fprintf(errOutput, "%v\n", err)

Copilot uses AI. Check for mistakes.
@rustyeddy rustyeddy merged commit f6f4690 into main Jan 4, 2026
7 checks passed
@rustyeddy rustyeddy deleted the copilot/add-cli-command-for-timers branch January 4, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ottoctl cli Timers

3 participants