23 ms·
No - 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 runt
by tmpfs 9y ago
No - 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