handlr-regex
handlr-regex copied to clipboard
Generate shell completion scripts rather than manually maintaining them
Generate shell completion scripts using clap_complete. This would make it easier to keep the completion scripts up to date with any changes to handlr's arguments as well as support other shells.
Ideally, a solution should use build.rs or cargo xtask and leverage the existing Cmd struct.
To do:
- [ ] Implement completion generation in cargo xtask
- [ ] Update GitHub Actions
Since handlr-regex relies on a hidden subcommand being run by completion scripts in order to have dynamic completion with mimetypes, file extensions, and desktop files of installed programs, this may not be feasible until clap-rs/clap#1232 has been resolved.
hi, as clap-rs/clap#1232 has been resolved, would you consider revisit this issue? also, would it be possible for the manpages to be dynamically genereated as well?
many thanks.
@minhtrancccp Nice! Thanks a lot for bringing it to my attention!
I'll certainly take a look at it when I can, but it could be a little while before I do because I have been busy lately and I have two other things to take care of first that other people have already been waiting on.
Namely, #76 and the ability to convert wildcards into matched mines mentioned in #75.
It might be possible to dynamically generate manpages on build, rather than running cargo xtask and committing them, but I have had issues trying to do this before. If nothing else, it's been a while since then and it might be worth revisiting as well.
Man pages are now dynamically generated at build time. I will give completion scripts a shot later.
Shell completion scripts are now generated on-the-fly. However, because of clap_complete's limitations, they are generated by running COMPLETE=<shell>, where <shell> is the name of the desired shell rather than at build time.
Fortunately, this can still be done ahead of time within packaging scripts for Linux distros anyways.