arikast / askbash

An intuitive yaml-driven bash auto-completion framework
MIT License
97 stars 3 forks source link

Emit native tab completion scripts #4

Open travis-bear opened 3 years ago

travis-bear commented 3 years ago

askbash parses the yaml configs and implements all the completion logic in the included ruby libraries. Control is handed off from bash's own completion mechanism to this package via complete -C and whatever askbash reports back to the shell is what it shows to the user as completion options.

This design choice comes with implications.

If I, as the author of a command line tool, want to use this package to generate my completions, then I have to tell my users to install askbash as well as my own utility. This causes extra friction for users, especially those who might not even have a Ruby runtime installed locally. I would rather be able to just provide them with a native bash completion script.

Compare askbash's installation workflow with other popular cli tools that provide rich completion options. For example, kubectl users can generate native bash (and zsh) specific completion scripts to standard out by running the kubectl completion command. Users of other common utilities can grab native completion scripts from the popular https://github.com/scop/bash-completion/tree/master/completions repo. None of these require that the end user install any additional gems or other forms of packaging.

Where I see a gap, and an opportunity for askbash, is in the creation of the shell-native completion scripts. Currently generating these scripts is manual, tedious, arcane, and error-prone. askbash has developed a beautiful configuration model with an elegant and simple yaml syntax. If that syntax could be used to emit native tab completion scripts it could simplify developer work and drive additional askbash adoption.

jamiesmith commented 2 years ago

@travis-bear I know that your comment is a year old but check out https://github.com/DannyBen/completely