Skip to main content

A UI package for Typer CLI apps.

Project description

Typer UI

PyPI version License: MIT Python Versions

Typer UI is a powerful Python library that automatically generates a web-based user interface for your Typer CLI applications. Built on top of NiceGUI, it provides a modern, interactive way to inspect and execute your commands without writing a single line of frontend code.

Typer UI Screenshot


🚀 Features

  • Zero Configuration: Instantly turn any Typer CLI into a web app.
  • Automatic Introspection: Detects commands, arguments, options, and types automatically.
  • Interactive Forms: Generates user-friendly inputs for string, integer, boolean, and choice parameters.
  • Real-time Output: View command execution logs (stdout/stderr) directly in the browser.
  • Type Safe: leverages Python type hints to generate the correct UI components.
  • Modern Design: Clean, responsive interface powered by NiceGUI.

📦 Installation

Install typer-ui via pip:

pip install typer-ui

Since typer-ui relies on typer and nicegui, they will be installed as dependencies.

🛠 Usage

Integrating typer-ui is incredibly simple. Just wrap your existing Typer application instance and call .run().

Example

Assuming you have a Typer app in main.py:

import typer
from typer_ui import TyperUI

app = typer.Typer()

@app.command()
def hello(name: str):
    print(f"Hello {name}")

@app.command()
def goodbye(name: str, formal: bool = False):
    if formal:
        print(f"Goodbye, Ms./Mr. {name}")
    else:
        print(f"Bye {name}!")

if __name__ == "__main__":
    # Create the TyperUI instance
    ui = TyperUI(app, title="My App UI")
    
    # Run the server
    ui.run()

Run your script:

python main.py

Your browser will automatically open showing the Typer UI interface at http://localhost:8080.

🎮 Demo

We have included a comprehensive demo in this repository to showcase the capabilities of existing CLIs.

To run the demo:

  1. Clone the repository:

    git clone https://github.com/amitb2050/typer-ui.git
    cd typer-ui
    
  2. Install dependencies: It is recommended to use a virtual environment.

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    pip install -e .
    
  3. Run the Demo UI: To see the UI in action, run the following command:

    python demo/run_ui.py
    

    You can also run the underlying CLI directly to compare:

    python demo/run.py --help
    

This will launch the UI for a sample CLI application (mycli) found in the demo directory. Explore the commands, try different inputs, and see the execution results live!

🤝 Contributing

Contributions are welcome! If you find a bug or feature request, please open an issue or submit a pull request.

  1. Fork the repository.
  2. Create a branch for your feature (git checkout -b feature/amazing-feature).
  3. Commit your changes.
  4. Push to the branch.
  5. Open a Pull Request.

Dev Environment

We use tox for automation. To run tests:

pip install tox
tox

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

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

typer_ui-0.1.2.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typer_ui-0.1.2-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file typer_ui-0.1.2.tar.gz.

File metadata

  • Download URL: typer_ui-0.1.2.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for typer_ui-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dd9a92e71748d8a2606cf0fa53459a0da05ebed6478df328e45bc7e8cf39ebc8
MD5 441339ba51657307a70db195655d0b68
BLAKE2b-256 24cfb4b1b18baae9ffa78c369651be6edfba4553d0a3dfd66add8056c4d6119a

See more details on using hashes here.

File details

Details for the file typer_ui-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: typer_ui-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for typer_ui-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 acb7bdd133cc2cd68cb5a436dad074c86471cb76d25fd2d4f356219077900f31
MD5 9506dff238e5a65d018486c59299e83e
BLAKE2b-256 a4ffab7e82c79f52fb5c300b68cf93f6683238713ed98d6fb24c3ebced87159f

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