[WIP] Autogenerate shell completions #336
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently someone mentioned compleat and this made me realize we already have (almost) all the necessary information to generate shell completion in our
lopts
array.So that's what this does. This is very much an early draft/proof of concept - so I'd like some feedback on the overall structure/direction of this (don't pay too much attention to small details at the moment).
Shells like zsh supports having a short description which can be helpful to the user, so I've added a
DESC
macro. But it's optional, so I can drop it if it's too invasive.To test out the zsh completion yourself, run the following (or equivalent) and then reload your shell:
$ tcc -run compautogen.c | doas tee /usr/local/share/zsh/site-functions/_scrot
Screenshot:
UPDATE: I think the generator is at a state where it is good enough.
However a couple other things need to be done before the PR can be merged:
create-man.sh
) to generate the output completion filesmake dist
(I'm thinking we shouldn't commit the generated files into git)install
target as wellThe last one might need more research since the "proper directory" to install completion files might vary distro to distro.