os_helper.cli_argparse module

OS Helper — argparse-based command-line interface.

Thin wrapper around the pure functions exported by os_helper that exposes the toolkit as subcommands under a single os-helper entry point. Written with argparse from the standard library so the CLI works out of the box on any Python install that has the package installed — no extra runtime dependency required.

The CLI is deliberately additive: it exists on top of the library API, never replaces it. Every existing public function stays importable from os_helper unchanged; each subcommand here is a shell-friendly wrapper that translates flags into keyword arguments.

Subcommand groups

  • os — operating-system detection (system / unix /

    linux / macos / windows / pid / workers / run / open)

  • path — path predicates and helpers (exists / dir-exists

    / join / abs / rel / no-home / size / split / glob / mkdir / rmdir / rm / cp)

  • hash — hashing (string / file / folder)

  • str — string utilities (empty / ascii)

  • config — configuration loading (get)

  • temp — temporary file helpers (file / folder)

  • misc — misc utilities (now / format-size / describe

    / url-ok / zip / download / time2str / str2time / ip)

  • prof — profiling (wall / cpu / gpu)

Usage Example

>>> #   os-helper os system
>>> #   os-helper path exists ~/somefile.txt
>>> #   os-helper hash string hello --size 8
>>> #   os-helper hash file ./pyproject.toml
>>> #   os-helper misc now --fmt filename
>>> #   os-helper misc format-size 12345678
>>> #   os-helper temp folder --prefix demo
>>> #   os-helper prof wall -- sleep 0.1

Author

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

os_helper.cli_argparse.build_parser()[source]

Assemble the top-level os-helper argument parser.

Returns:

Fully wired parser with every subcommand group attached.

Return type:

argparse.ArgumentParser

os_helper.cli_argparse.main(argv=None)[source]

Entry point invoked by os-helper (see [project.scripts]).

Parameters:

argv (sequence of str, optional) – Arguments to parse. Defaults to sys.argv[1:] when None.

Returns:

Process exit code (0 on success).

Return type:

int