trogon icon indicating copy to clipboard operation
trogon copied to clipboard

Support for argh

Open johndoe46 opened this issue 2 years ago • 5 comments

(Sorry if it's not the place to ask)

Is there any plan to support argh ? (https://pypi.org/project/argh/)

Thank you,

johndoe46 avatar May 21 '23 19:05 johndoe46

This is a very interesting topic. Similar projects such as Gooey or Wooey have the same limitation of origin, in that they are tied to CLIs implemented in a particular library (argparse in the case of those mentioned). For instance, see https://github.com/chriskiehl/Gooey/issues/478

It would be great to have an abstraction layer that allows to define CLIs implemented in any framework (and language!) in a common format (like OpenAPI does for http API), and that these tools that "augment" the interface are based on that instead of the internal API of a particular framework. Then you could have these interfaces almost for free for any CLI app.

I only found this (somehow) related [discussion in HN](https://news.ycombinator.com/item?id=34960260.

mgaitan avatar May 22 '23 01:05 mgaitan

Yes, as someone who does not enjoy click, and does enjoy plumbum, I'm eager to learn what the plans are regarding different CLI toolkits going forward.

AndydeCleyre avatar May 24 '23 20:05 AndydeCleyre

Working directly with argparse would be neat too - maybe something like this:

import argparse
from trogon import argparse_tui

parser = argparse.ArgumentParser(
    prog="ProgramName",
    description="What the program does",
    epilog="Text at the bottom of help"
)
parser.add_argument("filename")
parser.add_argument("-c", "--count")
parser.add_argument("-v", "--verbose", action="store_true")
argparse_tui(parser)

simonw avatar May 25 '23 19:05 simonw

AFAIU we need to define an equivalent introspection function for each different cli library. https://github.com/Textualize/trogon/blob/42564c53f96f062029c4adf104e8d4210e8f598c/trogon/introspect.py#L95

The "abstract layer" I mentioned is covered by the dataclasses (CommandSchema, ArgumentSchema, etc) in that module.

Also, trogon should not depend by default on click, but import the library needed dynamically, depending to the function/class of the decorated CLI app.

mgaitan avatar May 26 '23 03:05 mgaitan

I was going to comment here, but I instead created an issue that was more generic; not specific to this one library:

https://github.com/Textualize/trogon/issues/43

fresh2dev avatar Jun 09 '23 14:06 fresh2dev

Given open or past issues and comments asking about support for at least:

  • Typer
  • argh
  • argparse
  • python-fire
  • golang kong

It seems that #43 captures the more generally maintainable way forward.

daneah avatar Sep 20 '24 13:09 daneah