Skip to content

Commit 88b663c

Browse files
authored
Make frame-rate CLI options aliases (#564)
Closes #548 Makes `-f`, `--frame-rate`, and `--framerate` aliases of the same CLI option. All forms now appear in help and documentation. When multiple forms are used, Click uses the last value. Updates the related CLI tests.
2 parents e81ba12 + 0e8609f commit 88b663c

3 files changed

Lines changed: 7 additions & 21 deletions

File tree

docs/cli.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,10 @@ Options
6161

6262
Stats file (.csv) to write frame metrics. Existing files will be overwritten. Used for tuning detection parameters and data analysis.
6363

64-
.. option:: -f FPS, --frame-rate FPS
64+
.. option:: -f FPS, --framerate FPS, --frame-rate FPS
6565

6666
Override frame rate with value as frames/sec.
6767

68-
.. option:: --framerate FPS
69-
70-
Alias of :option:`-f/--frame-rate <-f>`.
71-
7268
.. option:: -m TIMECODE, --min-scene-len TIMECODE
7369

7470
Minimum length of any scene. TIMECODE can be specified as number of frames (-m 10), time in seconds (-m 2.5), or timecode (-m 00:02:53.633).

scenedetect/_cli/__init__.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,23 +230,14 @@ def print_command_help(ctx: click.Context, command: click.Command):
230230
)
231231
@click.option(
232232
"--frame-rate",
233+
"--framerate",
233234
"-f",
234235
"frame_rate",
235236
metavar="FPS",
236237
type=click.FLOAT,
237238
default=None,
238239
help="Override frame rate with value as frames/sec.",
239240
)
240-
# Keep --framerate separate so Click can hide it while mapping both spellings to frame_rate.
241-
@click.option(
242-
"--framerate",
243-
"frame_rate",
244-
metavar="FPS",
245-
type=click.FLOAT,
246-
default=None,
247-
hidden=True,
248-
help="Alias of -f/--frame-rate.",
249-
)
250241
@click.option(
251242
"--min-scene-len",
252243
"-m",

tests/test_cli.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,10 @@ def test_cli_detector_with_stats(tmp_path, detector_command: str):
337337

338338
@pytest.mark.parametrize(
339339
"option",
340-
["--frame-rate", "--framerate"],
340+
["--frame-rate", "--framerate", "-f"],
341341
)
342342
def test_cli_frame_rate_aliases(option: str):
343-
"""Both long frame-rate spellings are accepted by the CLI."""
343+
"""All frame-rate aliases are accepted by the CLI."""
344344
exit_code, _ = invoke_cli(
345345
["-i", DEFAULT_VIDEO_PATH, option, "30.0", "time", "-s", "2s", "-d", "4s"]
346346
)
@@ -360,13 +360,12 @@ def test_cli_frame_rate_aliases_last_value_wins(options: list[str], succeeds: bo
360360
assert (exit_code == 0) is succeeds
361361

362362

363-
def test_cli_framerate_alias_is_hidden():
364-
"""Help shows the primary frame-rate spellings but not the supported hidden alias."""
363+
def test_cli_framerate_alias_is_visible():
364+
"""Help shows all frame-rate aliases as one option."""
365365
exit_code, output = invoke_cli(["--help"])
366366

367367
assert exit_code == 0
368-
assert "-f, --frame-rate FPS" in output
369-
assert "--framerate" not in output
368+
assert "-f, --frame-rate, --framerate FPS" in output
370369

371370

372371
def test_cli_min_scene_len_accepts_all_timecode_forms(tmp_path: Path):

0 commit comments

Comments
 (0)