Last change
on this file since 307 was
228,
checked in by g7moreau, 6 years ago
|
- Add link dhcp-dns-tools in package
|
File size:
1.5 KB
|
Rev | Line | |
---|
[225] | 1 | # bash completion for ddt |
---|
[221] | 2 | |
---|
[225] | 3 | have ddt && |
---|
| 4 | _ddt() { |
---|
[221] | 5 | local cur prev |
---|
| 6 | |
---|
| 7 | COMPREPLY=() |
---|
| 8 | #_get_comp_words_by_ref cur prev |
---|
| 9 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 10 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 11 | |
---|
| 12 | case $prev in |
---|
| 13 | -b|--bootp) |
---|
[225] | 14 | local showlist=$(ddt show-pxe --no-header|awk '{print $1}') |
---|
[221] | 15 | COMPREPLY=($(compgen -W "${showlist}" -- "$cur")) |
---|
| 16 | return 0 |
---|
| 17 | ;; |
---|
| 18 | -d|--domainset) |
---|
[225] | 19 | local showlist=$(ddt show-domainset --no-header|awk '{print $1}') |
---|
[221] | 20 | COMPREPLY=($(compgen -W "${showlist}" -- "$cur")) |
---|
| 21 | return 0 |
---|
| 22 | ;; |
---|
| 23 | -p|--pool) |
---|
[225] | 24 | local showlist=$(ddt show-pool --no-header|awk '{print $1}') |
---|
[221] | 25 | COMPREPLY=($(compgen -W "${showlist}" -- "$cur")) |
---|
| 26 | return 0 |
---|
| 27 | ;; |
---|
| 28 | -k|--kind) |
---|
| 29 | COMPREPLY=($(compgen -W "dhcp pool-dhcp fix-address" -- "$cur")) |
---|
| 30 | return 0 |
---|
| 31 | ;; |
---|
| 32 | -t|--tag) |
---|
[225] | 33 | local showlist=$(ddt show-tag --no-header|awk '{print $1}') |
---|
[221] | 34 | COMPREPLY=($(compgen -W "${showlist}" -- "$cur")) |
---|
| 35 | return 0 |
---|
| 36 | ;; |
---|
| 37 | esac |
---|
| 38 | |
---|
| 39 | if [[ "$cur" == '-*' || $COMP_CWORD -gt 1 ]] |
---|
| 40 | then |
---|
[225] | 41 | COMPREPLY=($(compgen -W "$(ddt help|grep "^ ddt ${COMP_WORDS[1]}"|sed -e 's/[\[]/\n/g;'|grep -- '^-'|cut -f 1 -d ']'|cut -f 1 -d ' '|sed -e 's/|/ /g;'|xargs echo -n)" -- "$cur")) |
---|
[221] | 42 | else |
---|
[225] | 43 | COMPREPLY=($(compgen -W "$($(which ddt||echo /usr/local/bin/ddt) help|grep '^ ddt'|awk '{print $2}'|xargs echo -n)" -- "$cur")) |
---|
[221] | 44 | fi |
---|
| 45 | |
---|
[228] | 46 | } && complete -F _ddt ddt |
---|
| 47 | |
---|
| 48 | have dhcp-dns-tools && complete -F _ddt dhcp-dns-tools |
---|
Note: See
TracBrowser
for help on using the repository browser.