Skip to main content

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.toml setup
  • 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:

hello world example

(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 the 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, a usage message is printed.

Development

Run pytest with coverage report:

python3 -m pytest -s --cov=magicli --cov-report=term-missing

Metadata

Release files for magicli 2.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for magicli 2.2.1
File Size Uploaded Provenance Actions
magicli-2.2.1.tar.gz 23.2 kB Without provenance Details for magicli-2.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for magicli 2.2.1
File Interpreter ABI Platform Actions
magicli-2.2.1-py3-none-any.whl Python 3 none any Details for magicli-2.2.1-py3-none-any.whl

Total release size: 42.4 kB

Release files / magicli-2.2.1.tar.gz

Download URL magicli-2.2.1.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9beb41773bf391a9950f3f545d741f9df91d26ff8b135044fff0caf03edf52f1
BLAKE2b-256 checksum
How to use checksums
1c582449a3329687acd316e0f444c7bca6dc9173c06268c19ede132ce74594d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / magicli-2.2.1-py3-none-any.whl

Download URL magicli-2.2.1-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9494a6ec39aecc31cef2550cc94b385c2014308c7835ee3615fcf609ac7f1db1
BLAKE2b-256 checksum
How to use checksums
8e27995a557c2ed431345ebf53f2fbf3c7c05148619f8bb8617c8c3dfc9fb85d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for magicli 2.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page