Cyclopts

4.10.1 · active · verified Sun Mar 29

Cyclopts is a modern, easy-to-use command-line interface (CLI) framework built on Python type hints, offering an intuitive and efficient developer experience. It provides advanced type hinting support, rich help page generation from docstrings, and extensive customization options for parsing and launching. The library is actively maintained, currently at version 4.10.1, with frequent updates and ongoing development towards version 5.0.

Warnings

Install

Imports

Quickstart

This basic example demonstrates creating an `App` instance, registering a default command using the `@app.default` decorator, and defining parameters with type hints. Docstrings are automatically used to generate help messages. The `app()` call parses command-line arguments and executes the corresponding function.

from cyclopts import App

app = App()

@app.default
def main(name: str, count: int = 1):
    """Greets the given name(s).

    Parameters
    ----------
    name: str
        The name to greet.
    count: int
        Number of times to greet.
    """
    for _ in range(count):
        print(f"Hello, {name}!")

if __name__ == "__main__":
    # Example usage: python your_script.py World --count 3
    # Or: python your_script.py --help
    app()

view raw JSON →