News for hackers. Stuff that matters.
Re:Tools I use: argparse builder by pickledish on Thursday October 08, 2020 @10:38AM (#24719450)
I'd really love some kind of unified interface for program input.

Like, a Python program, a Ruby program, an online form, a REST API, and so on, all specify the input they need in ways specific to each tool (selecting from a predefined list is `CHOICES` param for argparse, a dropdown for a web form, etc). Why can't we just have some JSON spec for "input"? A list of params, each with a name, a description, a type, perhaps a list of possible choices -- the same sort of thing `argparse` exposes as its API.

Then, depending on the need, we can render that into a web page, or a parser, or whatever, and we can build libraries that can always expect to get input the same way without needing to redefine it all for each interface. Does something like this exist already and I just haven't seen it?

Re:Tools I use: argparse builder by toomanybeersies on Thursday October 08, 2020 @04:42PM (#24723737)
Sounds nice in theory, but with the state of modern development, this kind of thing will be implemented as a CLI frontend for an electron app.

But seriously though, the reason why this kind of standardised interface doesn't exist is because there's no one-size-fits-all solution. Everyone will "need" an extension to the spec, or start adding metasyntax to fit their specific use case.

Re:Tools I use: argparse builder by cameldrv on Thursday October 08, 2020 @01:09PM (#24721269)
I have been thinking of building something like this for some time. It would be great to have something that automatically generated a:

* CUI

* TUI

* Web UI

* REST API

* Config files

* Environment Variables

* GUI

There are pieces of this in various places. There are a number of command line libraries that integrate config files, command line options, and environment variables, including Traitlets (used in Jupyter). The original Enthought Traits did this for GUIs (declare a set of of classes with datatypes, call .configure_traits() on them, and voila, an autogenerated GUI for them. The Django admin interface is very similar for the web. What's needed is to bring this into a single package.

Re:Tools I use: argparse builder by albertzeyer on Friday October 09, 2020 @06:19AM (#24728480)
I also very much like this idea, as I find writing CUI/GUI code kind of boilerplate, annoying, and often feels like this is sth which could be automated.

In fact, I also implemented a similar idea to automatic GUI generation for my music player: https://github.com/albertz/music-player

I tried to summarize the idea here: https://github.com/albertz/wiki/blob/master/automatic-user-i...

Maybe you have some further good references?

Re:Tools I use: argparse builder by cxr on Thursday October 08, 2020 @10:55AM (#24719628)
> Does something like this exist already and I just haven't seen it?

OpenAPI (Swagger) kind of, although AFAIK it doesn't lend itself to specifying how to map things onto a CLI. A good next step for the project?

Re:Tools I use: argparse builder by aidenn0 on Thursday October 08, 2020 @11:13AM (#24719829)
Sounds a bit like SOAP, COM, or XML-RPC