capture_helper.cli_click module

Capture Helper — click-based command-line interface.

Twin of capture_helper.cli_argparse: same public surface (identical subcommand names, identical flag semantics), but implemented with click so users who already have a click-native shell setup (bash / zsh completion via click.shell_completion, colored --help, nested command groups) can plug it in without friction. Installed as the capture-helper-click entry point in pyproject.toml.

Design notes

  • Subcommands mirror capture-helper (the argparse twin) so both CLIs can be introspected identically by higher layers (FastAPI, MCP).

  • Flags reuse the argparse names (--kind / --name / …) rather than the more idiomatic click positional style — consistency across the two CLIs beats micro-idiomaticity here.

  • A library exception (e.g. pick_source’s ValueError when no device matches) is caught by the main() entry point and printed as one clean Error: ... line + exit 1 — click’s own error handling only covers its own ClickException/usage errors, not arbitrary exceptions raised inside a command body.

Usage Example

>>> #   capture-helper-click list-sources
>>> #   capture-helper-click pick-source --kind camera --name FaceTime
>>> #   capture-helper-click input-args --kind microphone --index 0
>>> #   capture-helper-click capture-camera --output-dir frames/ \
>>> #       --output-width 640 --output-height 360 --max-frames 30
>>> #   capture-helper-click capture-mic --output mic.wav --seconds 3

Author

Warith Harchaoui, Ph.D. — https://linkedin.com/in/warith-harchaoui/

capture_helper.cli_click.main()[source]

Console entry point (capture-helper-click).

Click’s own error handling only special-cases ClickException/ Abort (and a broken pipe) — a plain library exception (e.g. from pick_source) would otherwise propagate as a raw Python traceback instead of a clean CLI error. This wraps the whole invocation and translates that last case into a one-line stderr message + exit 1; click’s own control flow (usage errors, --help, an explicit sys.exit(1) in a subcommand) already raises SystemExit, a BaseException this does not catch, so it passes through untouched.

Return type:

None