Skip to main content

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

  1. pip install magicli
  2. magicli
  3. pip 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magicli-2.1.4.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

magicli-2.1.4-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file magicli-2.1.4.tar.gz.

File metadata

  • Download URL: magicli-2.1.4.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

Hashes for magicli-2.1.4.tar.gz
Algorithm Hash digest
SHA256 9ab026b526fb3f37d9ddc10679399ced1b54e4627747e67fb30cb2cbff5e299e
MD5 218265a0119b8ceaf41336c6d9722e96
BLAKE2b-256 35fbd1b9e8b2786ee459df206d012a514209b4df9d6bb05d4ccd990ca8b071a7

See more details on using hashes here.

File details

Details for the file magicli-2.1.4-py3-none-any.whl.

File metadata

  • Download URL: magicli-2.1.4-py3-none-any.whl
  • Upload date:
  • Size: 18.9 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

Hashes for magicli-2.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a264c869388d97f1feda314b098930197afb6cf42c9a709a771c92a7ea022347
MD5 63fb07818e0b969857de587f751e0ca6
BLAKE2b-256 4665e23da6b9ba9ba9daaa42a08ef5eef063e301125ed824583824856731f96d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page