servicer-labs / servicer

A CLI to simplify service management on systemd
https://servicer.dev
MIT License
427 stars 9 forks source link

Shell autocompletion #14

Open marchellodev opened 1 year ago

marchellodev commented 1 year ago

It would be great to have autocomplete when pressing tab to autocomplete for the command name or the service name for both zsh and bash.

For reference: https://askubuntu.com/questions/68175/how-to-create-script-with-auto-complete

secretshardul commented 12 months ago

Autocomplete for commands can be implemented with clap_complete but I have questions:

  1. Do we really need auto-complete for core commands like ser create, ser start or ser stop? The commands are short, also some of them have the same starting characters (st in start / stop / status). This defeats the point of auto-complete.

  2. There's value in auto-completion for service names. ser stop hel gets auto-completed to ser stop hello-world. The problem is that clap_help won't help not help because we need to read files from /etc/systemd/system/ and match them with the input text. We must write completion scripts by hand and need separate scripts for every shell editor (bash, zsh).

Got a few things at hand but will try to make time for #2. In the meantime contributions are appreciated