Skip to main content

Interfacy

Tests PyPI version Supported versions Downloads license

Interfacy is a CLI framework that turns Python functions, classes, and class instances into command-line interfaces. It derives the CLI from signatures, type annotations, and docstrings instead of making you define it twice.

Features

  • Generate CLIs from functions, classes, class methods, and class instances.
  • Nested subcommands and manual command groups with aliases.
  • Type-driven parsing from annotations, with support for custom parsers.
  • Model expansion for dataclasses, Pydantic models, and plain classes.
  • --help text generated from docstrings.
  • Highly customizable help output with multiple layouts, color themes, and configurable ordering.
  • Stdin piping support with configurable routing to parameters.
  • Optional tab completion via argcomplete.

Installation

From PyPI

pip install interfacy
uv add interfacy

From source

pip install git+https://github.com/zigai/interfacy.git
uv add "git+https://github.com/zigai/interfacy.git"

Quick Start

from interfacy import Interfacy


def greet(name: str, times: int = 1) -> None:
    """Print a greeting."""
    print(" ".join([f"Hello, {name}!" for _ in range(times)]))


if __name__ == "__main__":
    Interfacy().run(greet)
$ python app.py Ada
Hello, Ada!

$ python app.py Ada --times 2
Hello, Ada! Hello, Ada!

Agent Skill

The official AI agent skill can be installed from this repo.

npx skills add https://github.com/zigai/interfacy/tree/master/interfacy/.agents/skills/interfacy

or

uvx library-skills

Class-Based Commands

Classes become command namespaces. __init__ parameters live at the command level and public methods become subcommands.

from interfacy import Interfacy


class Calculator:
    def __init__(self, precision: int = 2) -> None:
        self.precision = precision

    def add(self, a: float, b: float) -> float:
        return round(a + b, self.precision)

    def mul(self, a: float, b: float) -> float:
        return round(a * b, self.precision)


if __name__ == "__main__":
    Interfacy(print_result=True).run(Calculator)
$ python app.py --precision 3 add 1.2345 2.3445
3.579

Structured Parameters

Dataclasses, Pydantic models, and plain classes with typed __init__ parameters can be expanded into nested flags and reconstructed before execution.

from dataclasses import dataclass
from interfacy import Interfacy


@dataclass
class Address:
    city: str
    postal_code: int


@dataclass
class User:
    name: str
    age: int
    address: Address | None = None


def greet(user: User) -> str:
    return f"Hello {user.name}, age {user.age}"


if __name__ == "__main__":
    Interfacy(print_result=True).run(greet)
$ python app.py --user.name Ada --user.age 32
Hello Ada, age 32

Manual Groups

Use CommandGroup when your command tree is not naturally rooted in one callable:

from interfacy import CommandGroup, Interfacy


def clone(url: str) -> str:
    return f"clone:{url}"


class Releases:
    def cut(self, version: str) -> str:
        return f"cut:{version}"


ops = CommandGroup("ops", description="Operational commands")
ops.add_command(clone)
ops.add_command(Releases)

if __name__ == "__main__":
    Interfacy(print_result=True).run(ops)

Interfacy CLI Entrypoint

Interfacy also ships a CLI that can run an existing function, class, or class instance directly from a module or Python file:

$ interfacy app.py:greet Ada
$ interfacy app.py:greet --help
$ interfacy package.cli:Calculator add 1 2

The entrypoint supports configuration via TOML, loaded from ~/.config/interfacy/config.toml or INTERFACY_CONFIG.

usage: interfacy [--help] [--version] [--config-paths] [TARGET] ...

Interfacy is a framework for building CLIs from Python callables.

positional arguments:
  [TARGET]        Python file or module with a function/class/instance symbol
                  (e.g. main.py:main, pkg.cli:App, pkg.cli:service).
  ...             Arguments passed through to the target command.

options:
  --help                Show this help message and exit
  --version             show version and exit.
  --config-paths        print config file search paths and exit.

Use 'interfacy TARGET --help' to display the help text for the target.

License

MIT License

Metadata

Release files for interfacy 0.9.2

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

Source distribution (sdist)

Source distribution for interfacy 0.9.2
File Size Uploaded
interfacy-0.9.2.tar.gz 164.3 kB Details

Built distribution (wheel)

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

Total release size: 380.5 kB

Release files / interfacy-0.9.2.tar.gz

Download URL interfacy-0.9.2.tar.gz
Size 164.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8e460e15874fd44b49fbb6efc65d449b6226385ae88fc58e26f005a1c12ade61
BLAKE2b-256 checksum
How to use checksums
6549cba5371ce14e544fdbfbb4e0111917b8b268c122b12eed5f7ce17e303219
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / interfacy-0.9.2-py3-none-any.whl

Download URL interfacy-0.9.2-py3-none-any.whl
Size 216.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a137fb77021a961b82f1d604f3d4571d24371c274c2222cfcb2e27419b4b776e
BLAKE2b-256 checksum
How to use checksums
c35f2def97788f0b26da3a059a08e347a91d3164236a7502b6ca22c1d260e81e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

0.9.2 This release

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

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