sftp_helper.cli_click module
SFTP Helper — click-based command-line interface.
Twin of sftp_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 sftp-helper-click entry point in pyproject.toml.
Design notes
Subcommands mirror
sftp-helper(the argparse twin) so both CLIs can be introspected identically by higher layers (FastAPI).Flags reuse the argparse names (
--config/--remote/ …) rather than the more idiomatic click positional style — consistency across the two CLIs beats micro-idiomaticity here.Errors from the library propagate unchanged; click handles the formatting.
Usage Example
>>> # sftp-helper-click upload --config settings.yaml --input local.txt --remote /uploads/local.txt
>>> # sftp-helper-click download --config settings.yaml --remote /uploads/local.txt --output out.txt
>>> # sftp-helper-click exists --config settings.yaml --remote /uploads/local.txt
>>> # sftp-helper-click mkdir --config settings.yaml --remote /uploads/a/b/c
- sftp_helper.cli_click.main()[source]
Console entry point (
sftp-helper-click).Click’s own
main()only special-casesClickException/Abort(and a broken pipe); a plain library exception (e.g. fromupload()) 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