Automatically generates a CLI from functions.
Project description
magiᴄʟɪ✨
Automatically generates a CLI from functions.
Install
pip install magicli
Get started
Simple usage example.
# module.py
def hello(name, times=1):
for _ in range(times):
print("hello", name)
import magicli
Make sure you import magicli at the end of the file.
$ python3 module.py world --times 2
hello world
hello world
Define name of CLI in pyproject.toml
Add the following to your pyproject.toml.
[project.scripts]
hello = "module:hello"
This example assumes the following project structure with the CLI to be created specified in the file module.py.
.
├── module.py
└── pyproject.toml
You can now pip install your code and call it like this:
$ hello world --times 2
hello world
hello world
Make sure to adjust the path to module if your project layout is different.
Using subcommands
# module.py
def hello(): ...
def world(times=1):
for _ in range(times):
print("hello world")
import magicli
$ 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, there will be no output.
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-1.2.0.tar.gz.
File metadata
- Download URL: magicli-1.2.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d8f2e4df177ea03d4830c471fc8fd6a73c2afd5feacc0df40ee8bd4c72554c2
|
|
| MD5 |
0ffe4d0f8521d2efd071277ff6a9daf6
|
|
| BLAKE2b-256 |
f1206d21d4123d02305b8da58d0976607eecc6c1a6db32d4afa6144f1d08928d
|
File details
Details for the file magicli-1.2.0-py3-none-any.whl.
File metadata
- Download URL: magicli-1.2.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e108446e56a97a8c738049903a3d3f63e6820a9d09c970a369d34810a196e018
|
|
| MD5 |
6db38d4e8cdc0ed6cc4199f6eada5912
|
|
| BLAKE2b-256 |
5355408dd9769e74fc4d06333ed8de7e02c12d07872a511b369db28eae42b1e7
|