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 line per function the script exposes,
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 line per function the script exposes,
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)
|