[swift-evolution] Publish shell completions scripts with the toolchain

Bouke Haarsma bouke at haarsma.eu
Tue Jul 4 00:29:17 CDT 2017


My message's formatting got all messed up, here's my plain text re-post:

Some time ago I've provided SwiftPM with shell completion scripts (see 
PR [#703][703]) for both Bash and ZSH. These completions are quite 
useful as shown in the following gifs;

Bash:
![Bash][1]
ZSH:
![ZSH][2]

They are currently included with the SwiftPM project (see [zsh][3] and 
[bash][4]), but only available to those that checkout the SwiftPM 
repository. That's a pity because the completion scripts are very 
useful to beginners learning Swift to explore available commands and 
flags, but also speeds up  experienced Swift users on the command line.

In order to reach the complete Swift community, I'd like to provide 
these scripts with the toolchain. In order to do this, I propose adding 
two files inside the toolchain at a location similar to the builtin 
completion scripts:

    /usr/local/share/zsh/functions/_swift
    /usr/local/share/bash-completion/completions/swift

In order to keep these files up-to-date, I've written a SwiftPM command 
that generates these completions files, based on the arguments 
available to the various `SwiftTool<>` commands. At the moment the 
compiler flags are hard-coded, but I'm sure we can also find a way to 
provide these as well. PR [#1256][1256] is the shell completion script 
generator and PR [#1257][1257] is the output of that generator.

I'd like to get some input in whether and how we can include these 
scripts / files into the toolchain; how to automate the script 
generation such that they remain up-to-date with every Swift release; 
and a way to make users aware of these scripts -- instructions on how 
to enable them for their shell.

--
Thanks,
Bouke

[1]: 
https://cloud.githubusercontent.com/assets/235882/18910038/8468299c-8576-11e6-954e-7b6c5749bba9.gif 

[2]: 
https://cloud.githubusercontent.com/assets/235882/18910036/805fb40a-8576-11e6-98ff-2114c9997bf6.gif 

[3]: 
https://github.com/apple/swift-package-manager/blob/master/Utilities/zsh/_swift 

[4]: 
https://github.com/apple/swift-package-manager/blob/master/Utilities/bash/completions 

[703]: https://github.com/apple/swift-package-manager/pull/703
[1256]: https://github.com/apple/swift-package-manager/pull/1256
[1257]: https://github.com/apple/swift-package-manager/pull/1257




More information about the swift-evolution mailing list