elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.65k stars 299 forks source link

Are there any good examples for custom completion script? #1822

Closed shannmu closed 3 months ago

shannmu commented 3 months ago

I am working on a project about Command Line Argument Parser, specifically the part about supporting dynamic completion. I saw in the elvish manual (https://elv.sh/ref/edit.html#edit:completion:start) that there are some APIs that might be used for completion, such as $edit:-dot, $edit:completion:arg-completer, $edit:completion:binding, $edit:completion:matcher, and $edit:current-command. However, I am not an elvish user, so I am not quite sure how to implement the completion feature for a command using elvish script. Are there any good examples available?

xiaq commented 3 months ago

Hi! You can find some in https://github.com/elves/awesome-elvish?tab=readme-ov-file#completion-scripts

iandol commented 3 months ago

@shannmu -- you may also be interested in carapace: https://carapace.sh and you can see how it generates elvish completions