# bash completion function for ratools/ractl
_racomplete_ractl() {
 local CUR=${COMP_WORDS[COMP_CWORD]}
 if [[ ${COMP_CWORD} -eq 1 ]]
 then
  COMPREPLY=( $(compgen -W "version log dump show" -- ${CUR}) )
  COMPREPLY+=( $(compgen -W "ra@eth0" -- ${CUR}) )
  COMPREPLY+=( $(compgen -W "mtu@eth0" -- ${CUR}) )
  COMPREPLY+=( $(compgen -W "sll@eth0" -- ${CUR}) )
  COMPREPLY+=( $(compgen -W "pi0@eth0" -- ${CUR}) )
  COMPREPLY+=( $(compgen -W "rdnss0@eth0" -- ${CUR}) )
  COMPREPLY+=( $(compgen -W "exp0@eth0" -- ${CUR}) )
  return 0
 fi
 case "${COMP_WORDS[1]}" in
  "log")
   if [[ ${COMP_CWORD} -eq 2 ]]
   then
    COMPREPLY=( $(compgen -W " info  warning  error " -- ${CUR}) )
    return 0
   fi
   ;;
  ra@*)
   if [[ ${COMP_CWORD} -eq 2 ]]
   then
    COMPREPLY=( $(compgen -W " create  destroy  enable  disable  kill  show  dump  set " -- ${CUR}) )
    return 0
   fi
   case "${COMP_WORDS[2]}" in
    "set")
     if [[ ${COMP_CWORD} -eq 3 ]]
     then
      COMPREPLY=( $(compgen -W " maximum-interval  minimum-interval  current-hop-limit  managed-flag  other-managed-flag  home-agent-flag  preference  ndp-proxy-flag  lifetime  reachable-time  retransmission-timer " -- ${CUR}) )
      return 0
     fi
     case "${COMP_WORDS[3]}" in
      "maximum-interval")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 600  0h10m0s " -- ${CUR}) )
        return 0
       fi
       ;;
      "minimum-interval")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 3  0h0m3s " -- ${CUR}) )
        return 0
       fi
       ;;
      "current-hop-limit")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 64  unspecified " -- ${CUR}) )
        return 0
       fi
       ;;
      "managed-flag")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " on  off " -- ${CUR}) )
        return 0
       fi
       ;;
      "other-managed-flag")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " on  off " -- ${CUR}) )
        return 0
       fi
       ;;
      "home-agent-flag")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " on  off " -- ${CUR}) )
        return 0
       fi
       ;;
      "preference")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " low  medium  high  reserved " -- ${CUR}) )
        return 0
       fi
       ;;
      "ndp-proxy-flag")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " on  off " -- ${CUR}) )
        return 0
       fi
       ;;
      "lifetime")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 1800  0h30m0s  no-default " -- ${CUR}) )
        return 0
       fi
       ;;
      "reachable-time")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 0  0h0m0s0ms  unspecified " -- ${CUR}) )
        return 0
       fi
       ;;
      "retransmission-timer")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 0  0h0m0s0ms  unspecified " -- ${CUR}) )
        return 0
       fi
       ;;
     esac
     ;;
   esac
   ;;
  mtu@*)
   if [[ ${COMP_CWORD} -eq 2 ]]
   then
    COMPREPLY=( $(compgen -W " create  destroy  enable  disable  show  dump  set " -- ${CUR}) )
    return 0
   fi
   case "${COMP_WORDS[2]}" in
    "set")
     if [[ ${COMP_CWORD} -eq 3 ]]
     then
      COMPREPLY=( $(compgen -W " auto-detect  link-mtu " -- ${CUR}) )
      return 0
     fi
     case "${COMP_WORDS[3]}" in
      "auto-detect")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " on  off " -- ${CUR}) )
        return 0
       fi
       ;;
      "link-mtu")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 1500  unspecified " -- ${CUR}) )
        return 0
       fi
       ;;
     esac
     ;;
   esac
   ;;
  sll@*)
   if [[ ${COMP_CWORD} -eq 2 ]]
   then
    COMPREPLY=( $(compgen -W " create  destroy  enable  disable  show  dump  set " -- ${CUR}) )
    return 0
   fi
   case "${COMP_WORDS[2]}" in
    "set")
     if [[ ${COMP_CWORD} -eq 3 ]]
     then
      COMPREPLY=( $(compgen -W " auto-detect  link-layer-address " -- ${CUR}) )
      return 0
     fi
     case "${COMP_WORDS[3]}" in
      "auto-detect")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " on  off " -- ${CUR}) )
        return 0
       fi
       ;;
      "link-layer-address")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 00:13:37:00:ba:be " -- ${CUR}) )
        return 0
       fi
       ;;
     esac
     ;;
   esac
   ;;
  pi*@*)
   if [[ ${COMP_CWORD} -eq 2 ]]
   then
    COMPREPLY=( $(compgen -W " create  destroy  enable  disable  show  dump  set " -- ${CUR}) )
    return 0
   fi
   case "${COMP_WORDS[2]}" in
    "set")
     if [[ ${COMP_CWORD} -eq 3 ]]
     then
      COMPREPLY=( $(compgen -W " on-link-flag  autonomous-flag  router-address-flag  valid-time  preferred-time  prefix " -- ${CUR}) )
      return 0
     fi
     case "${COMP_WORDS[3]}" in
      "on-link-flag")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " on  off " -- ${CUR}) )
        return 0
       fi
       ;;
      "autonomous-flag")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " on  off " -- ${CUR}) )
        return 0
       fi
       ;;
      "router-address-flag")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " on  off " -- ${CUR}) )
        return 0
       fi
       ;;
      "valid-time")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 2592000  30d0h0m0s  not-valid  infinity " -- ${CUR}) )
        return 0
       fi
       ;;
      "preferred-time")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 604800  7d0h0m0s  not-valid  infinity " -- ${CUR}) )
        return 0
       fi
       ;;
      "prefix")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 2001:db8::/64 " -- ${CUR}) )
        return 0
       fi
       ;;
     esac
     ;;
   esac
   ;;
  rdnss*@*)
   if [[ ${COMP_CWORD} -eq 2 ]]
   then
    COMPREPLY=( $(compgen -W " create  destroy  enable  disable  show  dump  set  add  del " -- ${CUR}) )
    return 0
   fi
   case "${COMP_WORDS[2]}" in
    "set")
     if [[ ${COMP_CWORD} -eq 3 ]]
     then
      COMPREPLY=( $(compgen -W " lifetime " -- ${CUR}) )
      return 0
     fi
     case "${COMP_WORDS[3]}" in
      "lifetime")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 300  0d0h5m0s  not-valid  infinity " -- ${CUR}) )
        return 0
       fi
       ;;
     esac
     ;;
    "add")
     if [[ ${COMP_CWORD} -eq 3 ]]
     then
      COMPREPLY=( $(compgen -W " server " -- ${CUR}) )
      return 0
     fi
     case "${COMP_WORDS[3]}" in
      "server")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 2001:db8::53 " -- ${CUR}) )
        return 0
       fi
       ;;
     esac
     ;;
    "del")
     if [[ ${COMP_CWORD} -eq 3 ]]
     then
      COMPREPLY=( $(compgen -W " server " -- ${CUR}) )
      return 0
     fi
     case "${COMP_WORDS[3]}" in
      "server")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 2001:db8::53 " -- ${CUR}) )
        return 0
       fi
       ;;
     esac
     ;;
   esac
   ;;
  exp*@*)
   if [[ ${COMP_CWORD} -eq 2 ]]
   then
    COMPREPLY=( $(compgen -W " create  destroy  enable  disable  show  dump  set " -- ${CUR}) )
    return 0
   fi
   case "${COMP_WORDS[2]}" in
    "set")
     if [[ ${COMP_CWORD} -eq 3 ]]
     then
      COMPREPLY=( $(compgen -W " type  payload " -- ${CUR}) )
      return 0
     fi
     case "${COMP_WORDS[3]}" in
      "type")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " 253 " -- ${CUR}) )
        return 0
       fi
       ;;
      "payload")
       if [[ ${COMP_CWORD} -eq 4 ]]
       then
        COMPREPLY=( $(compgen -W " babe1337 " -- ${CUR}) )
        return 0
       fi
       ;;
     esac
     ;;
   esac
   ;;
 esac
 return 1
}
complete -F _racomplete_ractl ractl
