73 lines
2.3 KiB
Bash
73 lines
2.3 KiB
Bash
#!/bin/bash
|
|
|
|
_tea_completion() {
|
|
local cur prev words cword
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
words=("${COMP_WORDS[@]}")
|
|
cword="${COMP_CWORD}"
|
|
|
|
# Seznam dostupných příkazů tea
|
|
local commands="issue pr repo org team login logout user repo clone fork help"
|
|
|
|
# Zkontroluje, zda je první příkaz `tea`
|
|
if [[ ${COMP_CWORD} -eq 1 ]]; then
|
|
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
|
|
return 0
|
|
fi
|
|
|
|
# Argumenty pro jednotlivé příkazy
|
|
case "${words[1]}" in
|
|
issue)
|
|
local issue_commands="list create close reopen comment"
|
|
COMPREPLY=( $(compgen -W "${issue_commands}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
pr)
|
|
local pr_commands="list create close reopen merge checkout"
|
|
COMPREPLY=( $(compgen -W "${pr_commands}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
repo)
|
|
local repo_commands="list create fork mirror delete"
|
|
if [[ ${COMP_CWORD} -eq 2 ]]; then
|
|
COMPREPLY=( $(compgen -W "${repo_commands}" -- ${cur}) )
|
|
return 0
|
|
fi
|
|
|
|
# Argumenty pro `repo create`
|
|
if [[ ${words[2]} == "create" ]]; then
|
|
local repo_create_args="--name --description --private --template --default-branch --license --gitignore"
|
|
COMPREPLY=( $(compgen -W "${repo_create_args}" -- ${cur}) )
|
|
return 0
|
|
fi
|
|
;;
|
|
org)
|
|
local org_commands="list create delete add-member remove-member"
|
|
COMPREPLY=( $(compgen -W "${org_commands}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
user)
|
|
local user_commands="info search list"
|
|
COMPREPLY=( $(compgen -W "${user_commands}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
team)
|
|
local team_commands="list create delete add-member remove-member"
|
|
COMPREPLY=( $(compgen -W "${team_commands}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
login)
|
|
local login_args="--hostname --token --user --password --otp"
|
|
COMPREPLY=( $(compgen -W "${login_args}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Registrace funkce pro tea
|
|
complete -F _tea_completion tea
|