youtube_helper.cli_click module

YouTube Helper — click-based command-line interface.

Twin of youtube_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 youtube-helper-click entry point in pyproject.toml.

Design notes

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

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

  • A library exception is caught by the main() entry point (not click’s own error handling, which only special-cases ClickException/Abort) and printed as a clean Error: ... line + exit 1, instead of a raw Python traceback.

Usage Example

>>> #   youtube-helper-click metadata     --url https://www.youtube.com/watch?v=YE7VzlLtp-4
>>> #   youtube-helper-click audio        --url https://www.youtube.com/watch?v=YE7VzlLtp-4 --output out.mp3
>>> #   youtube-helper-click resolve      --url https://www.youtube.com/watch?v=YE7VzlLtp-4 --prefer audio
>>> #   youtube-helper-click channel-info --url https://www.youtube.com/@blender

Author

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

youtube_helper.cli_click.main()[source]

Console entry point (youtube-helper-click).

click’s own main() only special-cases ClickException/Abort (and a broken pipe); a plain library exception (e.g. AssertionError from an invalid URL) 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