File size: 913 Bytes
c019761
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
_huggingface_download_completion() {
    local commands=("download" "upload" "repo-files" "env" "login" "whoami" "logout" "repo" "lfs-enable-largefiles" "scan-cache" "delete-cache" "tag" "version" "upload-large-folder")
    local cur="${COMP_WORDS[COMP_CWORD]}"
    
    # If no command has been specified, suggest commands
    if [[ $COMP_CWORD -eq 1 ]]; then
        COMPREPLY=( $(compgen -W "${commands[*]}" -- "$cur") )
        return
    fi

    # If the command is 'download', suggest model names
    if [[ ${COMP_WORDS[1]} == "download" ]]; then
        # Fetch available models from Hugging Face Model Hub
        local models=$(curl -s https://huggingface.co/api/models | jq -r '.[].modelId')
        
        # Generate completions based on fetched model names
        COMPREPLY=( $(compgen -W "$models" -- "$cur") )
        return
    fi
}

complete -F _huggingface_download_completion huggingface-cli