handlr-regex icon indicating copy to clipboard operation
handlr-regex copied to clipboard

Generate shell completion scripts rather than manually maintaining them

Open Anomalocaridid opened this issue 3 years ago • 4 comments

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

Anomalocaridid avatar Apr 06 '22 23:04 Anomalocaridid

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.

Anomalocaridid avatar Jun 26 '22 03:06 Anomalocaridid

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 avatar Sep 10 '24 11:09 minhtrancccp

@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.

Anomalocaridid avatar Sep 10 '24 14:09 Anomalocaridid

Man pages are now dynamically generated at build time. I will give completion scripts a shot later.

Anomalocaridid avatar Sep 29 '24 20:09 Anomalocaridid

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.

Anomalocaridid avatar Oct 13 '24 21:10 Anomalocaridid