auto-completions for bb.cli/dispatch
You can test it with
# install test script
bbin install io.github.sohalt/bbct
# install completions
# bash
bbct --org.babashka.cli/completion-snippet bash >> ~/.bashrc
# zsh
# ~/.zsh needs to be on the $fpath variable for zsh
# if it's not, add this to your ~/.zshrc before a line with "compinit":
# fpath+=(~/.zsh)
bbct --org.babashka.cli/completion-snippet zsh > ~/.zsh/_bbct
# fish
bbct --org.babashka.cli/completion-snippet fish > ~/.config/fish/completions/bbct.fish
@Sohalt Trying to test:
bbct --babashka.cli/completion-snippet zsh > /usr/local/share/zsh/site-functions/_bbct
I'm getting:
zsh: no such file or directory: /usr/local/share/zsh/site-functions/_bbct
The installation for zsh can vary a bit, depending on how your distro packages zsh.
Try echo $fpath from within zsh and put the _bbct file somewhere in a directory on that path.
Also I just rebased on main and force pushed a new version of bbct with the latest sha
What is the recommended approach for this Rust-based CLI package? I suppose they must have some user-friendly docs for this?
They use
$ your_program --bpaf-complete-style-zsh > ~/.zsh/_your_program (https://docs.rs/bpaf/latest/bpaf/_documentation/_2_howto/_1_completion/index.html)
Though that depends on ~/.zsh/ being on your $fpath (e.g. on my system ~/.zsh/ doesn't exist).
What definitely should work is this:
-
mkdir ~/.zsh - Add
fpath+=($HOME/.zsh)"in your.zshrcbefore a line that sayscompinitor similar. - Then
bbct --babashka.cli/completion-snippet zsh > ~/.zsh/_bbct.
Nice! First working result after doing that:
Tests are failing due to line endings on Windows. Does any of bash, zsh or fish even work on Windows? What's the situation there when using something like Cygwin?
Current limitations:
- only works with
cli/dispatch - only works with gnu-style options (starting with
-or--) - doesn't work well with options that take lists (e.g.
:coerce [:string])
We might want to add Powershell completions or so in the future, but let's not worry about that for now. Does the example Rust library support this? You can disable those tests for Windows
Does the example Rust library support this?
no afaics
You can disable those tests for Windows
how?
By wrapping the whole test body in:
(when-not (fs/windows?) ...)
By wrapping the whole test body in:
(when-not (fs/windows?) ...)
Sometimes things can be so simple :) I thought there was some yaml programming involved to configure the test runner or similar :sweat_smile: