Interfacy¶
Interfacy turns ordinary Python functions, classes, methods, and instances into command-line interfaces. It reads signatures, type annotations, defaults, and docstrings so your command behavior and your CLI contract stay in one place.
Features¶
Commands from functions, methods, classes, and instances.
Nested command trees from classes and
CommandGroup.Type conversion from annotations, including primitives, booleans, sequences, choices, models, and custom parsers.
Help text from docstrings with configurable layouts, colors, grouping, and sorting.
Runtime support for stdin, argument files, shell completion, exit codes, and interrupts.
Default argparse backend and optional Click backend.
Install¶
pip install interfacy
uv add interfacy
Basic usage¶
from interfacy import Interfacy
def greet(name: str, times: int = 1) -> None:
"""Print a greeting."""
for _ in range(times):
print(f"Hello, {name}!")
if __name__ == "__main__":
Interfacy().run(greet)
$ python app.py Ada --times 2
Hello, Ada!
Hello, Ada!
Required non-boolean parameters become positionals. Optional parameters become flags. Boolean parameters become toggles. Docstrings provide help text.