os_helper.cli_click module
OS Helper — click-based command-line interface.
Twin of os_helper.cli_argparse: same public surface (identical
subcommand groups, identical flag semantics), but implemented with
click so users who already have a click-native shell setup
(click.shell_completion for bash / zsh / fish, colored --help,
nested command groups) can plug it in without friction. Installed as
the os-helper-click entry point in pyproject.toml.
Design notes
Subcommand groups mirror
os-helper(the argparse twin) so both CLIs can be introspected identically by higher layers.Flag names match the argparse names (
--path/--size/ …) rather than the more idiomatic click positional style — consistency across the two CLIs beats micro-idiomaticity here.A library exception is caught by
main()(the actualos-helper-clickconsole-script target) and printed as a cleanError: ...line + exit 1, instead of a raw traceback. Click’s own control flow (usage errors,--help, an explicitsys.exit) raisesSystemExit, which this does not catch, so it passes through unchanged.
Usage Example
>>> # os-helper-click os system
>>> # os-helper-click path exists /etc/hosts
>>> # os-helper-click hash string hello --size 8
>>> # os-helper-click misc now --fmt filename
>>> # os-helper-click temp folder --prefix demo
- os_helper.cli_click.config_grp()
Configuration loading (JSON / YAML / .env / env vars).
- Return type:
None
- os_helper.cli_click.hardware_grp()
Hardware inspection (CPU, RAM, GPU).
- Return type:
None
- os_helper.cli_click.hardware_info_cmd()
Print CPU cores/model, RAM, and GPU vendor/model/VRAM as JSON.
- Return type:
None
- os_helper.cli_click.hash_grp()
Hashing helpers (RIPEMD-160 / BLAKE2b fallback).
- Return type:
None
- os_helper.cli_click.main()[source]
Console entry point (
os-helper-click).Click’s own error handling only special-cases
ClickException/Abort(and a broken pipe); a plain library exception (e.g. aRuntimeErrorfromget_config) 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.exitin a subcommand) already raisesSystemExit, aBaseExceptionthis does not catch, so it passes through untouched.- Return type:
None
- os_helper.cli_click.misc_grp()
Miscellaneous utilities.
- Return type:
None
- os_helper.cli_click.misc_ip()
Fetch the caller’s public IPv4 / IPv6 addresses.
- Return type:
None
- os_helper.cli_click.os_grp()
Operating-system detection and process helpers.
- Return type:
None
- os_helper.cli_click.os_pid()
Print the current process ID.
- Return type:
None
- os_helper.cli_click.os_system()
Print the current OS name.
- Return type:
None
- os_helper.cli_click.path_grp()
Filesystem predicates and helpers.
- Return type:
None
- os_helper.cli_click.prof_grp()
Profile an arbitrary subcommand.
- Return type:
None
- os_helper.cli_click.str_grp()
String utilities.
- Return type:
None
- os_helper.cli_click.temp_grp()
Temporary file / folder helpers.
- Return type:
None