reitzig / sdkman-for-fish

Adds support for SDKMAN! to fish
MIT License
280 stars 13 forks source link

Remove redundancies in completions #5

Closed reitzig closed 5 years ago

reitzig commented 5 years ago

Currently, the pattern is

complete -c sdk -f -n '__fish_sdkman_no_command' -a 'cmd' -d 'Some command'
complete -c sdk -f -n '__fish_sdkman_no_command' -a 'c' -d 'Some command'
complete -c sdk -f -n '__fish_sdkman_using_command cmd' -a "(__fish_sdkman_candidates)"  
complete -c sdk -f -n '__fish_sdkman_using_command c' -a "(__fish_sdkman_candidates)"  

These can be combined like so:

complete -c sdk -f -n '__fish_sdkman_no_command' -s 'c' -l 'cmd' -d 'Some command'
complete -c sdk -f -n '__fish_sdkman_using_command cmd' -a "(__fish_sdkman_candidates)"  # ?

This not only cleans up the code, but also removes the duplicates from the completion list.

Apply to all completions.

reitzig commented 5 years ago

I spoke too quickly: -s and -l are only for -c and --long-c, that is with hyphens.

For sdk, we can use -a 'c long-c' which removes the redundancy from the sources, but not from the output.