drone-cli icon indicating copy to clipboard operation
drone-cli copied to clipboard

Add Bash completions

Open hwittenborn opened this issue 3 years ago • 9 comments

This pull request adds Bash completions for all of Drone's commands and sub-commands.


Notes regarding implementation:

  • Short options (i.e. -h, -s, etc etc.) aren't shown as flags in completions, as there's not really much to complete in them.
  • Long options are hidden on commands that have subcommands until a hyphen is typed on the current argument (i.e. for drone plugins, --help won't be shown as a completion option until at least - is typed).
  • The above implementation was based off that off apt-get, which has the same behavior.
  • This PR doesn't aim to add completions for any dynamic data (i.e. things like repositories or users), though if that's a must I'd be more than glad to look into implementing such.

hwittenborn avatar Dec 11 '21 09:12 hwittenborn

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Dec 11 '21 09:12 CLAassistant

Any thoughts @bradrydzewski @tphoney?

hwittenborn avatar Jan 16 '22 18:01 hwittenborn

Hey @hwittenborn many thanks for looking into this. I am bad person, i kept meaning to try this out and haven,t. mia culpa

If i wanted to test this locally what do i need to do ? how do i test this ?

tphoney avatar Jan 27 '22 13:01 tphoney

Great! Not a problem on the wait :)

To test everything locally, you should just need to run source ./drone.bash from a Bash shell in the directory containing the completion file.

You should then be able to use the completion normally as if it were packaged up and everything. I wasn't sure if you were familiar with completions either, but you should be able to use them by typing drone and then hitting the Tab key a few times, after which it'll just keep suggesting while your type with further Tab kep presses.

hwittenborn avatar Jan 27 '22 22:01 hwittenborn

@tphoney: Any update on this?

hwittenborn avatar Feb 27 '22 08:02 hwittenborn

👀 now, apologies. I was doing a fair bit of work on drone-cli to improve signing linting and exec.

tphoney avatar Mar 01 '22 13:03 tphoney

First off, its is soo awesome. So i gave it a test drive 🚗 , and when i tried it in my default shell zsh. It did not work. Once i flipped my shell to bash everything was 😎 So my question would be, do you know if there is much of an effort to add additional shell support.

tphoney avatar Mar 01 '22 13:03 tphoney

I don't use ZSH myself, but I've heard it has Bash completion emulation, so I'll look into setting that up for this.

Did an error pop up when you used it under ZSH though, or did it just not work?

hwittenborn avatar Mar 01 '22 17:03 hwittenborn

I was doing a fair bit of work on drone-cli to improve signing linting and exec.

All good too :)

hwittenborn avatar Mar 01 '22 17:03 hwittenborn

This PR has been automatically closed due to inactivity.

bot-harness avatar Oct 19 '23 11:10 bot-harness