Skip to content

Add --playback-speed CLI flag for controlling replay speed#266

Open
sh4wnbk wants to merge 1 commit into
IAmTomShaw:mainfrom
sh4wnbk:feature/playback-speed-flag
Open

Add --playback-speed CLI flag for controlling replay speed#266
sh4wnbk wants to merge 1 commit into
IAmTomShaw:mainfrom
sh4wnbk:feature/playback-speed-flag

Conversation

@sh4wnbk

@sh4wnbk sh4wnbk commented Mar 30, 2026

Copy link
Copy Markdown

Summary

Adds a --playback-speed CLI flag so users can set the initial replay speed from the command line.

Closes #36

Problem

playback_speed was hardcoded to 1 in main.py with no way to control it via CLI. Users could only change playback speed interactively after the replay launched.

Changes

  • Added --playback-speed argument parsing in main.py, consistent with the existing --year and --round patterns
  • Defaults to 1.0 if the flag is not provided

Usage

python main.py --viewer --year 2024 --round 12 --playback-speed 2.0
python main.py --viewer --year 2024 --round 5 --playback-speed 0.5

Note: Valid speed values are constrained by PLAYBACK_SPEEDS in race_replay.py ([0.1, 0.2, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0]). Values not in this list will fall back to 1.0 — this behaviour is inherited from the existing window logic and unchanged by this PR.

Copilot AI review requested due to automatic review settings March 30, 2026 21:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new CLI flag to control the initial replay speed when launching the viewer, addressing the inability to set playback speed from the command line.

Changes:

  • Added --playback-speed parsing in main.py
  • Set default playback speed to 1.0 when the flag is omitted

Comment thread main.py
Comment on lines +138 to +142
if "--playback-speed" in sys.argv:
speed_index = sys.argv.index("--playback-speed") + 1
playback_speed = float(sys.argv[speed_index])
else:
playback_speed = 1
playback_speed = 1.0 # Default playback speed

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

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

--playback-speed parsing can crash with IndexError (flag provided without a value) or ValueError (non-numeric value). Consider validating speed_index < len(sys.argv) and wrapping float(...) in try/except to print a helpful message and exit (or fall back to the default). Also consider keeping the default type consistent by using 1.0 throughout (the main() default is currently an int).

Copilot uses AI. Check for mistakes.
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.

Improve CLI: Add --speed flag, error handling, and fix default year

2 participants