A cli tool that makes any Python function an executable
Project description
Bistrot
A cli tool that transforms any Python function into an executable, or can easily print any constant in a codebase or library
It takes an existing Python function in a project and allows you to call it as an independent executable. All the function arguments become cli arguments with argparse.
Examples
Let's consider this example from examples/ops.py:
#examples/ops.py
def add(a: int, b: int) -> int:
return a + b
We can call this function from the command line using bistrot:
$ bistrot examples.ops:add --x=2 --y=3
5
It also works with static and class methods
#examples/klass.py
import bistrot
class UsefulClass:
@staticmethod
def version():
return bistrot.__version__
$ bistrot examples.klass:UsefulClass.version
0.1.0
The same result can be achieved by targeting directly the __version__
variable:
$ bistrot bistrot:__version__
0.1.0
Warning
This project is still experimental and is guaranteed to work only with primitive Python types.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for bistrot-0.1.0a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ace0c35f458e395c2e77c3678e21febecae7f2e5ceca928da28840a6714aa8f |
|
MD5 | 8cd879737e19a9bf1d25761100aac354 |
|
BLAKE2b-256 | 44b2d29c316a3147881baaf21f2f87ae50926c407589032ac37da133674e9fac |