Open yarikoptic opened 4 years ago
FWIW I’ve tried this a few times, and it always leads to headache. This seems like one of those pretty things that would just make maintainership hard. But maybe there is an old school way to just generate a shell script to do the completion, and then install alongside? We did this back in the day for Singularity. I’m averse you adding buggy things that don’t add a ton, so my initial response is “probably not.”
100% agree and I had exactly the same thought! is there a tool already to produce from argparse complete sourceable completion scripts? (I think I did search at some point, forgot details now) But with that in mind I remain hopeful since idea is indeed nice and allows for dynamic handling (not that some shims could be provided for that other tool ;))
Yeah good point! I'll leave the issue open for future thinking / discussion.
eh, it is that day... right after this I saw a tweet about poetry, README of which says "poetry supports generating completion scripts for Bash, Fish, and Zsh", so now I am down that rabbit hole
ohhhh.... oh no, lol.
But that would require using it.
they use https://github.com/sdispater/cleo for cmdline interfacing. Never heard about it, but it is the one supporting generating them "natively"
I wish only if it also provided Pythonic interface for defined "Commands" (that is what we do in DataLad) -- I would have even closed by eyes on dislike of defining interface in docstrings (and not the other way around), and tried to use it where I ATM use click. ... although again -- seems more magic dust is needed:
$> ./demo_cleo.py completions bash >| demo_cleo_completions
$> bash
$> source demo_cleo_completions
$> ./demo_cleo.py bash: _get_comp_words_by_ref: command not found
bash: __ltrim_colon_completions: command not found
I am still fighting to make it work for me in datalad but it used to work and works for others: https://github.com/kislyuk/argcomplete/ . Use could be as rudimentary as just following argparse spec or add fancier "dynamic" completions