3 ms·
Do the compiled JSON files have direct compatibility with any JS argument parsing libraries? I read through everything and it wasn't clear to me whether you are
by foob 9y ago
Do the compiled JSON files have direct compatibility with any JS argument parsing libraries? I read through everything and it wasn't clear to me whether you are on your own once you get the JSON or if there is an automated way to make use of these.
It's an awesome project in either case, but it would be incredibly useful if this could somehow be a stepping stone towards a more language agnostic way of defining command-line interfaces. I do a fair bit of language hopping and it can be frustrating how much the quality of argument parsing frameworks varies between language ecosystems. It's even worse from a user perspective when a utility's interface was obviously determined by the limitations of its language or argument parsing library.
- tmpfs 9y agoNo - not direct compatibility per se, because I don't think it's the responsibility of the argument parsing library to work with the definition. The nodejs runtime[1] uses a lightweight argparse[2] library which is implemented as a plugin. You can then enable additional plugins for argument validation or any other processing you require. Effectively you end up with two objects, one describing the program and another describing the parsed arguments which should then be passed through a plugin pipeline. The existing runtime plugins[3] illustrate this. > if there is an automated way to make use of these. There is using the nodejs runtime, take a look at the source for the mkcli program[4] to get a feel for how it works. > stepping stone towards a more language agnostic way of defining command-line interfaces I couldn't agree more, ideally we would implement runtimes in most of the mainstream languages using the pattern described above :) Hope that helps & thanks for the feedback! [1]: https://github.com/mkdoc/mkcli-runtime https://github.com/mkdoc/mkcli-runtime [2]: https://github.com/cli-kit/cli-argparse https://github.com/cli-kit/cli-argparse [3]: https://github.com/mkdoc/mkcli-runtime/tree/master/plugin https://github.com/mkdoc/mkcli-runtime/tree/master/plugin [4]: https://github.com/mkdoc/mkdoc/blob/master/cli/cli.js https://github.com/mkdoc/mkdoc/blob/master/cli/cli.js