Last updated:
0 purchases
bistrot 0.1.0a4
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
bistrot> 5
Or it can use positional arguments if they are defined as such in the function:
$ bistrot examples.ops:add 2 3
bistrot> 5
However, the mandatory arguments must all be either positional or named in a cli call.
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
bistrot> 0.1.0a1
The same result can be achieved by targeting directly the __version__ variable:
$ bistrot bistrot:__version__
bistrot> 0.1.0a1
It is also possible to call methods on strings
$ bistrot '{\"hello\"}:upper'
bistrot> HELLO
Install
Bistrot is on pypi and it has no dependencies! Install it simply with
$ pip install bistrot
Or you may want to install it with pipx for global usage
$ pipx install bistrot
$ bistrot <cmds>
And verify your installation with
$ bistrot --version
bistrot> 0.1.0a1
Warning
This project is still experimental and is guaranteed to work only with primitive Python types.
Links
Source Code: https://github.com/mattiadg/bistrot
PyPI Releases: https://pypi.org/project/bistrot/
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.