Skip to content

stepup.core.call

Dispatch decorator and driver for scripts invoked by call().

The driver is the explicit entry point: add it to every worker script called via call():

if __name__ == "__main__":
    driver()

driver()

Dispatch a function by name when a script is invoked via call().

Add this to every worker script called via call():

if __name__ == "__main__":
    driver()

When invoked with no function argument, driver() prints one suggested command per callable function and exits, which is useful for discovery.

Source code in stepup/core/call.py
def driver() -> None:
    """Dispatch a function by name when a script is invoked via `call()`.

    Add this to every worker script called via `call()`:

    ```python
    if __name__ == "__main__":
        driver()
    ```

    When invoked with no function argument, `driver()` prints one suggested command
    per callable function and exits, which is useful for discovery.
    """
    ns = inspect.currentframe().f_back.f_globals
    script_path = ns.get("__file__", sys.argv[0])
    args = _parse_args(script_path)
    if args.function is None:
        _print_list(script_path, ns)
    else:
        _dispatch(script_path, ns, args)