Skip to content

Add CLI arguments for session simulation replay#234

Open
Abasz wants to merge 2 commits into0.9.8-In-Developmentfrom
simulation-cli-flags-support
Open

Add CLI arguments for session simulation replay#234
Abasz wants to merge 2 commits into0.9.8-In-Developmentfrom
simulation-cli-flags-support

Conversation

@Abasz
Copy link
Copy Markdown
Collaborator

@Abasz Abasz commented Apr 9, 2026

Description:

This replaces the commented-out simulation block in server.js with proper CLI arguments, enabling replay of recorded rowing sessions without modifying source code.

What changed

  • Extracted CLI argument parsing into SimulationArgs.js
  • server.js conditionally activates simulation only when --simulate is passed
  • Added npm run simulate convenience script to package.json
  • Added unit tests for all argument combinations in SimulationArgs.test.js
  • It uses Node's built in parse argument helper that is robust

Defaults preserve current behavior

All defaults match the original commented-out block exactly:

  • File: Concept2_RowErg_Session_2000meters.csv
  • Delay: 30000ms
  • Realtime: enabled
  • Looping: enabled

Without --simulate, the server behaves identically to before — this is a zero-impact change for production.

Available flags

Flag Description
--simulate Enable session replay
--simulateFile <path> Override the default recording file
--simulateDelay <ms> Override the startup delay
--simulateOnce Run the replay once instead of looping
--simulateFast Replay at maximum speed instead of realtime

Benefits over the old approach

  • No source code changes needed — no risk of accidentally committing an uncommented debug block
  • Flexible — file path, delay, looping, and speed are all configurable per invocation
  • Testable — parsing logic is isolated and covered by 7 unit tests
  • Discoverablenpm run simulate makes it easy for new contributors to find

Example usage

# Default simulation (same as the old commented block)
node app/server.js --simulate

# Custom file, fast, single run
node app/server.js --simulate --simulateFile recordings/WRX700_2magnets.csv --simulateFast --simulateOnce

Abasz added 2 commits April 9, 2026 19:47
Replace the commented-out simulation block in server.js with CLI
arguments that enable replay of recorded rowing sessions without code
changes.

New flags:
  --simulate       Enable session replay (default: off)
  --simulateFile   Path to CSV recording (default: Concept2)
  --simulateDelay  Startup delay in ms (default: 30000)
  --simulateOnce   Run replay once instead of looping
  --simulateFast   Replay at max speed instead of realtime

Parsing logic extracted to SimulationArgs.js with full test coverage.
Adds npm run simulate convenience script.
Fall back to the default 30000ms delay when a non-numeric, empty, or
negative value is passed via --simulateDelay. Add edge case tests for
invalid delay, empty string, negative values, and unknown flags.
@Abasz Abasz force-pushed the simulation-cli-flags-support branch from 84d0ef3 to 663ee80 Compare April 9, 2026 19:47
@Abasz Abasz changed the base branch from main to 0.9.8-In-Development April 9, 2026 19:47
@JaapvanEkris JaapvanEkris added this to the 0.9.8 milestone Apr 10, 2026
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.

2 participants