mirror of
https://github.com/kazhala/dotbare
synced 2024-11-02 09:40:27 +00:00
feat(complete:bash): completion for third level commands
This commit is contained in:
parent
0b665b2aae
commit
9f53730dbd
@ -22,12 +22,39 @@ _dotbare_completions()
|
||||
else
|
||||
COMPREPLY=($(compgen -W "${subcommands}" -- "${COMP_WORDS[1]}"))
|
||||
fi
|
||||
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
|
||||
COMPREPLY=( "${COMPREPLY[0]%% *}" )
|
||||
fi
|
||||
|
||||
elif [[ "$COMP_CWORD" -eq "2" && "${prev}" != '-h' ]]; then
|
||||
case "${prev}" in
|
||||
fbackup)
|
||||
options="$(${mydir}/dotbare ${prev} -h \
|
||||
| awk '{
|
||||
if ($0 ~ / -p PATH/) {
|
||||
gsub(/^ -p PATH/, "-p ", $0)
|
||||
gsub(/\t/, " ", $0)
|
||||
print $0
|
||||
} else if ($0 ~ / -*/) {
|
||||
gsub(/^ /, "", $0)
|
||||
gsub(/\t/, " ", $0)
|
||||
print $0
|
||||
}
|
||||
}')"
|
||||
;;
|
||||
finit)
|
||||
options="$(${mydir}/dotbare ${prev} -h \
|
||||
| awk '{
|
||||
if ($0 ~ / -u URL/) {
|
||||
gsub(/^ -u URL/, "-u ", $0)
|
||||
gsub(/\t/, " ", $0)
|
||||
print $0
|
||||
} else if ($0 ~ / -*/) {
|
||||
gsub(/^ /, "", $0)
|
||||
gsub(/\t/, " ", $0)
|
||||
print $0
|
||||
}
|
||||
}')"
|
||||
;;
|
||||
*)
|
||||
options="$(${mydir}/dotbare ${prev} -h \
|
||||
@ -38,14 +65,15 @@ _dotbare_completions()
|
||||
print $0
|
||||
}
|
||||
}')"
|
||||
COMPREPLY=($(compgen -W "${options}" -- "${COMP_WORDS[2]}"))
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
|
||||
COMPREPLY=( "${COMPREPLY[0]%% *}" )
|
||||
COMPREPLY=($(compgen -W "${options}" -- "${COMP_WORDS[2]}"))
|
||||
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
|
||||
COMPREPLY=( "${COMPREPLY[0]%% *}" )
|
||||
fi
|
||||
elif [[ "$COMP_CWORD" -eq "3" ]]; then
|
||||
[[ "${COMP_WORDS[1]}" == "fbackup" && "${COMP_WORDS[2]}" == "-p" ]] && \
|
||||
COMPREPLY=($(compgen -d -- "${COMP_WORDS[3]}"))
|
||||
fi
|
||||
}
|
||||
|
||||
complete -F _dotbare_completions dotbare
|
||||
|
Loading…
Reference in New Issue
Block a user