Skip to content

Commit 81e6a56

Browse files
authored
[cli] Move output command state out of CliContext (#426)
* [cli] Move output command state out of CliContext To simplify things, all output commands can be treated similarily as they all act on the result of the processing pipeline. This allows new commands to be added without needing to explicitly define their values in CliContext, and makes the values that do remain there much more meaningful. It also allows commands to be specified multiple times gracefully and with different options, so for example `save-images` can now be run twice with different encoding parameters. * [cli] Centralize preconditions in CliContext * [cli] Simplify parsing of default values
1 parent e58f0e3 commit 81e6a56

File tree

8 files changed

+618
-790
lines changed

8 files changed

+618
-790
lines changed

scenedetect/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
def main():
2424
"""PySceneDetect command-line interface (CLI) entry point."""
25-
cli_ctx = CliContext()
25+
context = CliContext()
2626
try:
2727
# Process command line arguments and subcommands to initialize the context.
28-
scenedetect.main(obj=cli_ctx) # Parse CLI arguments with registered callbacks.
28+
scenedetect.main(obj=context) # Parse CLI arguments with registered callbacks.
2929
except SystemExit as exit:
3030
help_command = any(arg in sys.argv for arg in ["-h", "--help"])
3131
if help_command or exit.code != 0:
@@ -38,12 +38,12 @@ def main():
3838
# no progress bars get created, we instead create a fake context manager. This is done here
3939
# to avoid needing a separate context manager at each point a progress bar is created.
4040
log_redirect = (
41-
FakeTqdmLoggingRedirect() if cli_ctx.quiet_mode else logging_redirect_tqdm(loggers=[logger])
41+
FakeTqdmLoggingRedirect() if context.quiet_mode else logging_redirect_tqdm(loggers=[logger])
4242
)
4343

4444
with log_redirect:
4545
try:
46-
run_scenedetect(cli_ctx)
46+
run_scenedetect(context)
4747
except KeyboardInterrupt:
4848
logger.info("Stopped.")
4949
if __debug__:
@@ -52,7 +52,7 @@ def main():
5252
if __debug__:
5353
raise
5454
else:
55-
logger.critical("Unhandled exception:", exc_info=ex)
55+
logger.critical("ERROR: Unhandled exception:", exc_info=ex)
5656
raise SystemExit(1) from None
5757

5858

0 commit comments

Comments
 (0)