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

hello world example

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.5.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.5-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

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

Hashes for magicli-2.1.5.tar.gz
Algorithm Hash digest
SHA256 e090a9f8493258acbdba84f15fa0dcf1a6717d0ab88665087cdc32aa80c47409
MD5 6166147eb6c3335a60fea7fc0e32a8ab
BLAKE2b-256 1f8b19f93c19e83129abf288a86bda70c001bf18a0701166f192948d4789ea05

See more details on using hashes here.

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

Hashes for magicli-2.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2d8401f77276da3891a3b999a5ea3fddc426303218626f4ca44c9650b5d4a294
MD5 e0452f30bb9c5ca7a269c1ee5703abb8
BLAKE2b-256 9342bacc288dc489db4bbdf9e139a8e6855fbc6c951f5266ff1d56eac97150e9

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