Skip to content

feat: add --watch flag for real-time auto-refresh#25

Open
Haut wants to merge 1 commit intoPolymarket:mainfrom
Haut:feat/watch-flag
Open

feat: add --watch flag for real-time auto-refresh#25
Haut wants to merge 1 commit intoPolymarket:mainfrom
Haut:feat/watch-flag

Conversation

@Haut
Copy link

@Haut Haut commented Feb 28, 2026

Summary

  • Adds a global --watch <SECONDS> flag that re-runs any command at a configurable interval with screen clearing
  • Enables live monitoring of prices, orderbooks, orders, positions, and other data
  • Rejects --watch with JSON output mode and zero-second intervals with clear error messages
  • Clean Ctrl+C exit handling via tokio::signal

Usage

polymarket --watch 5 clob price <TOKEN> --side buy   # refresh price every 5s
polymarket --watch 3 clob book <TOKEN>               # live orderbook
polymarket --watch 10 clob orders                    # monitor open orders
polymarket --watch 10 data positions <ADDR>          # track portfolio

Implementation

  • ~25 lines of new logic in src/main.rs only — zero changes to command or output modules
  • No new crate dependencies (only adds "signal" feature to existing tokio)
  • Global flag follows existing --output pattern via clap global = true

Test plan

  • cargo build compiles without errors
  • cargo test — all 146 tests pass (94 unit + 52 integration), including 3 new tests
  • --watch appears in --help output
  • --watch with -o json is rejected with error
  • --watch 0 is rejected with error
  • Manual: cargo run -- --watch 3 status refreshes every 3s, Ctrl+C exits cleanly

Note

Low Risk
Low risk: adds an opt-in CLI loop around existing command execution plus a tokio feature flag, with no changes to business logic or data/auth flows.

Overview
Adds a global --watch <seconds> flag to re-run the selected CLI command on an interval, clearing the screen and showing a timestamped header each refresh.

--watch is explicitly rejected for JSON output and for a 0 interval, and uses tokio::signal::ctrl_c() to exit cleanly. Integration tests cover help output and the validation errors, and tokio is built with the signal feature (updating Cargo.lock accordingly).

Written by Cursor Bugbot for commit 994a15b. This will update automatically on new commits. Configure here.

Adds a global --watch <SECONDS> flag that re-runs any command at a
configurable interval with screen clearing, enabling live monitoring
of prices, orderbooks, positions, and other data.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

alloy = { version = "1.6.3", default-features = false, features = ["providers", "sol-types", "contract", "reqwest", "reqwest-rustls-tls", "signer-local", "signers"] }
clap = { version = "4", features = ["derive"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros", "signal"] }
Copy link

Choose a reason for hiding this comment

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

Missing explicit time feature for tokio dependency

Medium Severity

The watch_loop function calls tokio::time::sleep, which requires the "time" feature flag on the tokio dependency. The Cargo.toml change only adds "signal" but not "time" to tokio's features. This compiles today solely because a transitive dependency (reqwest via alloy) happens to enable tokio/time. If that transitive chain ever changes (e.g., a dependency upgrade removes or alters the reqwest dependency), the build will break.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant