Automatically generates a CLI from functions.
Project description
magiᴄʟɪ✨
magicli
automatically turns a file into a CLI by introspecting its functions.
- no boilerplate
- automatic help message
- type casting included
- supports sub-commands
- complete
pyproject.tomlsetup - ready for upload to
pypi
Create a full CLI in only 2 lines of code:
# hello.py
def hello(name, greeting="hello"):
print(greeting, name)
calling magicli creates this CLI:
(animated terminal created with clivio)
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 .
or after uploading to pypi:
pip install <package_name>
Advanced use
Using subcommands
# hello.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.2.0.tar.gz.
File metadata
- Download URL: magicli-2.2.0.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","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 |
d32ba679f5dd0b8fd69c4e5040df04b239214f24bf95048a6223f959d3a98ce3
|
|
| MD5 |
7d4c08fddd95cc499133e84904fd9628
|
|
| BLAKE2b-256 |
5f2e3a3aa47aaa7f8334800644395b8ac403535dd498b399e87663abeef5afb2
|
File details
Details for the file magicli-2.2.0-py3-none-any.whl.
File metadata
- Download URL: magicli-2.2.0-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","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 |
5430b5017046ccc57cf4016f2aaf509e4007b36d2b7d9f679d2e2e4fdc387b56
|
|
| MD5 |
fb703752471e30f838a393e33e12904c
|
|
| BLAKE2b-256 |
9aa46925d0ff4b0dc8769d933b464da72bd46c54987e83ad7b45a03864a7b3f2
|