Skip to main content

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


Download files

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

Source Distribution

magicli-1.0.0.tar.gz (2.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-1.0.0-py2.py3-none-any.whl (2.8 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: magicli-1.0.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.5.13

File hashes

Hashes for magicli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8168d064b2b29001d0cd53f2a485718cf0d64ae0e28cd0976752d62fdf23106e
MD5 3583718bd778cf5f1d06bb8697b2b0f0
BLAKE2b-256 9a22227893077baffb27e5dbf505bb2fc9a5a2834e699d5f65bc2af542f90287

See more details on using hashes here.

File details

Details for the file magicli-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: magicli-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.5.13

File hashes

Hashes for magicli-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c62290dc5eabeed35a3a259ffa1f9be149ff565d2e866173859f5e121c5ed5c9
MD5 639a509e2ca56b583da61b22c01bd166
BLAKE2b-256 9eda607889fb0ddffa5dc27765488b309268f2b5bc7213e9a903cdf5d4b0589c

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