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’sValueErrorwhen no device matches) is caught by themain()entry point and printed as one cleanError: ...line + exit 1 — click’s own error handling only covers its ownClickException/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
- 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. frompick_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 explicitsys.exit(1)in a subcommand) already raisesSystemExit, aBaseExceptionthis does not catch, so it passes through untouched.- Return type:
None