5 ms·
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 th
by pickledish 6y ago
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?
- federico_c 6y agohttps://github.com/shellcomp/shellcomp.github.io/blob/master/index.md https://github.com/shellcomp/shellcomp.github.io/blob/master... https://github.com/oilshell/oil/wiki/Shellac-Protocol-Proposal https://github.com/oilshell/oil/wiki/Shellac-Protocol-Propos...
- cxr 6y ago> 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?
- aidenn0 6y agoSounds a bit like SOAP, COM, or XML-RPC
- O_H_E 6y agoObligatory XKCD: https://xkcd.com/927/ https://xkcd.com/927/
- cameldrv 6y agoI 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.
- albertzeyer 6y agoI 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 https://github.com/albertz/music-player I tried to summarize the idea here: https://github.com/albertz/wiki/blob/master/automatic-user-interface.md https://github.com/albertz/wiki/blob/master/automatic-user-i... Maybe you have some further good references?
- toomanybeersies 6y agoSounds 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.