Open eighthave opened 4 years ago
Black use click as its command line parser library. click has a related library named click-completion to generate bash/zsh/fish completions. It is no need to write shell completion manually, just need someone who know click-completion to add this feature.
This is method: https://click.palletsprojects.com/en/8.1.x/shell-completion/
Should contact the packager of linux distribution to do this job for black and blackd.
And this issue can be closed. :smile:
BTW, click's completion seems to have space to improve.
Expected behaviour:
❯ black --help <TAB>
no more arguments
Actual:
❯ black --help --<TAB>
unsorted
--code Format the code passed in as a string.
--line-length How many characters per line to allow.
--target-version Python versions that should be supported by Black's output. [default: per-file auto-detection]
--pyi Format all input files like typing stubs regardless of file extension (useful when piping source on standard input).
black does not have bash-completion, hitting tab brings up nothing. I wrote up a quick bash-completion script that can be included under the same license as black uses. There are dynamic completion methods, where the bash-completion is generated from the Python code, but many Python devs find the required changes weird.
To test this, since this into either _/etc/bashcompletion.d/black or __: