Textualize / trogon

Easily turn your Click CLI into a powerful terminal application
MIT License
2.4k stars 54 forks source link

Make `click` optional; support manual definition of schemas. #43

Open fresh2dev opened 1 year ago

fresh2dev commented 1 year ago

Today, Trogon only supports click, and click-specific code is exists throughout Trogon. Frankly, Trogon is too amazing to be specific to click.

In addition to the reverse-engineering ("introspection") method of building a Trogon TUI from an existing click CLI, Trogon should offer an interface for any library to integrate Trogon by manually building and providing the command-schemas to Trogon. This way, Trogon could function without click, and any CLI app would have the ability to build and display a Trogon TUI. This would also lessen the burden on Trogon development, since it would not be necessary for Trogon devs to build "introspector" logic for each desired library, but would instead give devs of those libraries a path to D.I.Y. Trogon integration.

Instead of Trogon devs working to reverse-engineer and support this library and others, the developers of each library should have a path to integrate Trogon themselves.

Related issue: https://github.com/Textualize/trogon/issues/5

royatt commented 1 year ago

It would be fitting IMO to have some kind of a frontend abstraction layer, both for the inbound commands schema and for the outbound command execution. Imagine using the trogon engine to pick and choose different flags from a click CLI program, and to spew out the results back through into a more generic data-form that can (amongst still being totally fit for CLI reconstruction), would also support creating a pythonic function call that can be passed directly to the main function of click. (Interactive click based apps that use a shared state over a global and single python interpreter anyone?)

fresh2dev commented 1 year ago

That's not relevant to this issue. This issue is about making Trogon work well without click.

fresh2dev commented 1 year ago

Here is a POC of Trogon working with argparse:

https://asciinema.org/a/VR1nYMQEu0vBGmCm9bZRoDEOc

mgielda commented 6 months ago

This would be very interesting and greatly broaden the reach of Trogon, given the popularity of argparse. Of course assuming that the implementation would be a matter of adding a few lines into your code.

fresh2dev commented 6 months ago

Here's my fork that works with argparse: https://github.com/fresh2dev/argparse-tui