-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common core for man pages, etc? #41
Comments
One aspect of how practical this would be is how well we can define the common definition and integrate it into the parsers. Using traits for describing a CLI means that the CLI parser will need to implement them and would put them in the public API and would require an extra dependency. Using custom structs means that a crate on top could convert between the CLI parser and the common definition but there is a little bit more of overhead (could probably borrow for most/all strings?). Could also offer both. |
man page generator maybe - this is something that can be in theory shared. That said I already have a working copy implemented in a private branch, about 100 lines in total, mostly boring templating code. Not particularly interested in publishing it, experiments for now - what can be done. For completions - #40 is done, will be publishing it in a day or two after I do some more testing. Are there any reasons to prefer static completions? Dynamic seems to be easier to implement (took me a weekend) - for static ones you'll have to deal with a bunch of different shells and more useful in general - experimenting with a cargo thing to autocomplete parameters to binaries and examples in a current workspace. Common definition might be interesting, but if you look at |
Do you have any code or any notes already? |
If you already have a form of man pages and only care about dynamic completions, probably not worth it at this time. Part of my interest in this (and projects like
Benefits of dynamic completions
Benefits of static completions
Overall, I prefer the dynamic completion approach and want to move clap in that direction (we have a PoC of it).
Most of what you listed deal with parsing semantics which isn't needed for man pages. For arguments, its just a question of what flags and value names exist for it, the help, and maybe one or two other details. Even static completions can get away with basic parsing semantics and don't need more complex parsing nuance.
We have clap-rs/clap#2912 but it doesn't have much in the way of details as I've been focusing in other areas. |
Completions are not shipped with the binary, monad runner is. It adds about extra 40kb - bpaf 0.5.x apps with completions should be smaller than 0.4.x without them... Will probably be even less after I look at what takes up most of the size :)
Any shell that supports calling a function "command arguments" -> "completions" should be possible to support dynamically.
I see.. Yea, for manpages it's enough to dump flags/parameters/etc along with help messages. But once you get that the difference between dumping them and dumping manpage itself is kind of small.
Thank you, will take a look tomorrow. |
Came up with this with man page specific stuff sitting in Taking a closer look at |
An idea I've been kicking around is providing an API for describing a CLI, that is agnostic of the parser, so man pages, completions, etc can be shared across parsers. Describing a full CLI gets into a lot of parser-specialized knowledge, but at least something like man pages relies on such a small subset of information that I suspect it could be possible. I suspect the same could be true for static completions but probably not dynamic completions (which I see you are going with in #40).
This something of interest for collaborating on?
The text was updated successfully, but these errors were encountered: