Create huggingface-cli-completion.sh
Browse files
huggingface-cli-completion.sh
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_huggingface_download_completion() {
|
2 |
+
local commands=("download" "upload" "repo-files" "env" "login" "whoami" "logout" "repo" "lfs-enable-largefiles" "scan-cache" "delete-cache" "tag" "version" "upload-large-folder")
|
3 |
+
local cur="${COMP_WORDS[COMP_CWORD]}"
|
4 |
+
|
5 |
+
# If no command has been specified, suggest commands
|
6 |
+
if [[ $COMP_CWORD -eq 1 ]]; then
|
7 |
+
COMPREPLY=( $(compgen -W "${commands[*]}" -- "$cur") )
|
8 |
+
return
|
9 |
+
fi
|
10 |
+
|
11 |
+
# If the command is 'download', suggest model names
|
12 |
+
if [[ ${COMP_WORDS[1]} == "download" ]]; then
|
13 |
+
# Fetch available models from Hugging Face Model Hub
|
14 |
+
local models=$(curl -s https://huggingface.co/api/models | jq -r '.[].modelId')
|
15 |
+
|
16 |
+
# Generate completions based on fetched model names
|
17 |
+
COMPREPLY=( $(compgen -W "$models" -- "$cur") )
|
18 |
+
return
|
19 |
+
fi
|
20 |
+
}
|
21 |
+
|
22 |
+
complete -F _huggingface_download_completion huggingface-cli
|