Gitfed
bastien-mrq/sssh / completions / _sssh
#compdef sssh
# Complétion zsh pour sssh — à copier dans un répertoire du fpath, ex. :
#   mkdir -p ~/.zsh/completions && cp _sssh ~/.zsh/completions/
#   # puis dans ~/.zshrc, avant compinit :
#   fpath=(~/.zsh/completions $fpath)

_sssh() {
    local -a names subcmds
    names=(${(f)"$(sssh list --names 2>/dev/null)"})
    subcmds=(
        'add:Ajouter un host'
        'edit:Éditer un host'
        'rm:Supprimer un host'
        'list:Lister les hosts'
        'export:Exporter hosts.toml'
        'import:Importer un hosts.toml'
        'import-ssh:Importer depuis ~/.ssh/config'
        'help:Aide'
        'version:Version'
    )

    if (( CURRENT == 2 )); then
        _describe -t hosts 'host SSH' names
        _describe -t commands 'commande' subcmds
        return
    fi

    case $words[2] in
        edit|rm)
            (( CURRENT == 3 )) && _describe -t hosts 'host SSH' names
            ;;
        import|export)
            _files
            ;;
    esac
}

_sssh "$@"