Closed N-R-K closed 6 months ago
I was looking at mpv
recently and the way they do auto-completion is by having a --list-options
flag which outputs all the flags. The completion scripts then uses that output to configure itself.
I think this is probably a better approach than doing build time generation. It'll likely also attract more contributor since there are more people who can write shell scripts than people who can (or are willing to) write generators in C.
Closing in favor of https://github.com/resurrecting-open-source-projects/scrot/pull/377
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:
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.