MCPcopy Index your code
hub / github.com/Textualize/trogon

github.com/Textualize/trogon @v0.6.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.0 ↗ · + Follow
131 symbols 463 edges 20 files 28 documented · 21% updated 14mo agov0.6.0 · 2024-10-02★ 2,83543 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<img src="https://github.com/Textualize/trogon/assets/554369/f4751783-c322-4143-a6c1-d8c564d4e38f" alt="A picture of a trogon (bird) sitting on a laptop" width="300" align="center">

Discord

Trogon

Auto-generate friendly terminal user interfaces for command line apps.

🎬 Video demonstration

 

A quick tour of a Trogon app applied to sqlite-utils.

https://github.com/Textualize/trogon/assets/554369/c9e5dabb-5624-45cb-8612-f6ecfde70362

Trogon works with the popular Click library for Python, but will support other libraries and languages in the future.

How it works

Trogon inspects your (command line) app and extracts a schema which describes the options / switches / help etc. It then uses that information to build a Textual UI you can use to edit and run the command.

Ultimately we would like to formalize this schema and a protocol to extract or expose it from apps. This which would allow Trogon to build TUIs for any CLI app, regardless of how it was built. If you are familiar with Swagger, think Swagger for CLIs.

Screenshots

Screenshot 2023-05-20 at 12 07 31 Screenshot 2023-05-20 at 12 08 21
Screenshot 2023-05-20 at 12 08 53 Screenshot 2023-05-20 at 12 09 47

Why?

Command line apps reward repeated use, but they lack in discoverability. If you don't use a CLI app frequently, or there are too many options to commit to memory, a Trogon TUI interface can help you (re)discover options and switches.

What does the name mean?

This project started life as a Textual experiment, which we have been giving birds' names to. A Trogon is a beautiful bird I was lucky enough to photograph in 2017.

See also Frogmouth, a Markdown browser for the terminal.

Roadmap

Trogon is usable now. It is only 2 lines (!) of code to add to an existing project.

It is still in an early stage of development, and we have lots of improvements planned for it.

Installing

Trogon may be installed with PyPI.

pip install trogon

Quickstart

Click

  1. Import from trogon import tui
  2. Add the @tui decorator above your click app, e.g. ```python from trogon import tui

    @tui() @click.group(...) def cli(): ... `` 3. Your click app will have a newtui` command available.

Typer

  1. Import from trogon.typer import init_tui
  2. Pass your Typer CLI app into the init_tui function, e.g. python cli = typer.Typer(...) init_tui(cli)
  3. Your Typer app will have a new tui command available.

See also the examples folder for two example apps.

Custom command name and custom help

By default the command added will be called tui and the help text for it will be Open Textual TUI.

You can customize one or both of these using the command= and help= parameters:

@tui(command="ui", help="Open terminal UI")
@click.group(...)
def cli():
    ...

Follow this project

If this app interests you, you may want to join the Textual Discord server where you can talk to Textual developers / community.

Core symbols most depended-on inside this repo

focus
called by 7
trogon/widgets/form.py
_form_changed
called by 5
trogon/widgets/form.py
to_cli_args
called by 4
trogon/run_command.py
process_cli_option
called by 4
trogon/introspect.py
to_cli_string
called by 3
trogon/run_command.py
process_command
called by 3
trogon/introspect.py
make_widget_group
called by 3
trogon/widgets/parameter_controls.py
_update_execution_string_preview
called by 2
trogon/trogon.py

Shape

Method 77
Function 29
Class 24
Route 1

Languages

Python100%

Modules by API surface

trogon/trogon.py23 symbols
trogon/widgets/parameter_controls.py22 symbols
trogon/widgets/form.py15 symbols
trogon/widgets/multiple_choice.py10 symbols
trogon/introspect.py10 symbols
trogon/widgets/command_info.py8 symbols
trogon/widgets/about.py8 symbols
tests/test_run_command.py8 symbols
trogon/run_command.py7 symbols
tests/test_help.py6 symbols
trogon/widgets/command_tree.py5 symbols
examples/demo.py4 symbols

For agents

$ claude mcp add trogon \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact