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.1.1.tar.gz (2.9 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.1.1-py2.py3-none-any.whl (3.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for magicli-1.1.1.tar.gz
Algorithm Hash digest
SHA256 e394177b7228bb41da7938296db52f59615cbc05bc0696f6d347cf3f75d0e683
MD5 32231b04f41d87541b5026c437658c3f
BLAKE2b-256 3ec8f8688f0f38523805169f2f034402823d43dc42faac75c76f84f3b30e6a4f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for magicli-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a07e4b5ee845c7af676639dfa4349ce7095733641ba9104f0ce23d6b0afec862
MD5 90ffa5e2d05ad8312e67af32a581e37b
BLAKE2b-256 23ef00027ed7d5c1bc1b4d5fbf1c365d448ea178b7f9cca83d8b4c4fdfb945bd

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