#!/bin/fish

set CDS_COMMAND "cds"
function _completeCds
    set -l line (commandline -cp)
    set -l words (string split " " -- $line)

    # double quoting needed to avoid word 'h' to be recognized as command shortcut 'help'
    echo ($CDS_COMMAND completion --shell fish --prev "'$words[-2]'" --curr "'$words[-1]'" --line "'$line'")
end

# split into string array so result is not interpreted as single string
complete -c $CDS_COMMAND --no-files --keep-order --arguments "(_completeCds | string split ' ')"
