Automatically generates a CLI from functions.
Project description
magiᴄʟɪ✨
Automatically turns a file into a CLI without any boilerplate by introspecting its functions.
hello world example
# hello.py
def hello(name, greeting="hello"):
print(greeting, name)
becomes
with only 3 commands
pip install magiclimagiclipip install .
Quick start
Install magicli
pip install magicli
Setup your repository
Initialize repo
git init
Add version info (optional)
git tag 1.0.0
Automatically create CLI
magicli
Make sure the name of your CLI, the module name and the name of the function have to same name.
Install your Python package
pip install .
Advanced use
Using subcommands
# module.py
def hello(): ...
def world(times=1):
for _ in range(times):
print("hello world")
$ hello world --times 2
hello world
hello world
Help message
By default, the docstring of the function will be displayed.
If no docstring is specified, an error message will be printed.
Development
Run pytest with coverage report:
python3 -m pytest -s --cov=magicli --cov-report=term-missing
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file magicli-2.1.5.tar.gz.
File metadata
- Download URL: magicli-2.1.5.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e090a9f8493258acbdba84f15fa0dcf1a6717d0ab88665087cdc32aa80c47409
|
|
| MD5 |
6166147eb6c3335a60fea7fc0e32a8ab
|
|
| BLAKE2b-256 |
1f8b19f93c19e83129abf288a86bda70c001bf18a0701166f192948d4789ea05
|
File details
Details for the file magicli-2.1.5-py3-none-any.whl.
File metadata
- Download URL: magicli-2.1.5-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d8401f77276da3891a3b999a5ea3fddc426303218626f4ca44c9650b5d4a294
|
|
| MD5 |
e0452f30bb9c5ca7a269c1ee5703abb8
|
|
| BLAKE2b-256 |
9342bacc288dc489db4bbdf9e139a8e6855fbc6c951f5266ff1d56eac97150e9
|