source: trunk/ddt/ddt.bash_completion @ 222

Last change on this file since 222 was 221, checked in by g7moreau, 6 years ago
  • Add project ddt (dhcp-dns-tools)
File size: 2.3 KB
Line 
1# bash completion for dhcp-dns-tools
2
3have dhcp-dns-tools &&
4_dhcp_dns_tools() {
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)
14         local showlist=$(dhcp-dns-tools show-pxe --no-header|awk '{print $1}')
15         COMPREPLY=($(compgen -W "${showlist}" -- "$cur"))
16         return 0
17         ;;
18      -d|--domainset)
19         local showlist=$(dhcp-dns-tools show-domainset --no-header|awk '{print $1}')
20         COMPREPLY=($(compgen -W "${showlist}" -- "$cur"))
21         return 0
22         ;;
23      -p|--pool)
24         local showlist=$(dhcp-dns-tools show-pool --no-header|awk '{print $1}')
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)
33         local showlist=$(dhcp-dns-tools show-tag --no-header|awk '{print $1}')
34         COMPREPLY=($(compgen -W "${showlist}" -- "$cur"))
35         return 0
36         ;;
37   esac
38
39   if [[ "$cur" == '-*' || $COMP_CWORD -gt 1 ]]
40   then
41      COMPREPLY=($(compgen -W "$(dhcp-dns-tools help|grep "^ dhcp-dns-tools ${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"))
42   else
43      COMPREPLY=($(compgen -W "$($(which dhcp-dns-tools||echo /usr/local/bin/dhcp-dns-tools) help|grep '^ dhcp-dns-tools'|awk '{print $2}'|xargs echo -n)" -- "$cur"))
44   fi
45
46#   if [[ "$cur" == -* ]]; then
47#      COMPREPLY=( $( compgen -W '-h -d -i -p -m -c' -- "$cur" ) )
48#   else
49#      COMPREPLY=( $( compgen -W 'add_alias add_dhcp add_float add_static add_virtual \
50#         create_pool \
51#         change_mac change_ip change_host change_comment change_tag change_domainset \
52#         del_pc del_float \
53#         disable_pc disable_float enable_pc enable_float \
54#         gen_dhcp_file gen_dns_file check_dns \
55#         load_database \
56#         create_domainset show_domainset \
57#         create_pxe remove_pxe show_pxe enable_pxe disable_pxe \
58#         create_tag remove_tag show_tag \
59#         show search_mac \
60#         help' -- "$cur" ) )
61#   fi
62
63   } && complete -F _dhcp_dns_tools dhcp-dns-tools
Note: See TracBrowser for help on using the repository browser.