
    _pcs()
    {
    local cur cur1 cur2 cur3
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    if [ "$COMP_CWORD" -gt "0" ]; then cur1="${COMP_WORDS[COMP_CWORD-1]}";fi
    if [ "$COMP_CWORD" -gt "1" ]; then cur2="${COMP_WORDS[COMP_CWORD-2]}";fi
    if [ "$COMP_CWORD" -gt "2" ]; then cur3="${COMP_WORDS[COMP_CWORD-3]}";fi

    
case "${cur3}" in
  constraint)
    ;;
  resource)
    ;;
  cluster)
    ;;
  config)
  case "${cur2}" in
    import-cman)
      ;;
    export)
      case "${cur1}" in
        pcs-commands|pcs-commands-verbose)
          COMPREPLY=($(compgen -W "output=<filename>" -- ${cur}))
          return 0
          ;;
        *)
        ;;
      esac
      
      ;;
    checkpoint)
      ;;
    *)
    ;;
  esac
  
    ;;
  status)
    ;;
  pcsd)
    ;;
  stonith)
    ;;
  node)
    ;;
  property)
    ;;
  acl)
    ;;
  *)
  ;;
esac


case "${cur2}" in
  constraint)
  case "${cur1}" in
    rule)
      COMPREPLY=($(compgen -W "remove add" -- ${cur}))
      return 0
      ;;
    location)
      COMPREPLY=($(compgen -W "show remove add" -- ${cur}))
      return 0
      ;;
    order)
      COMPREPLY=($(compgen -W "show remove set" -- ${cur}))
      return 0
      ;;
    colocation)
      COMPREPLY=($(compgen -W "show remove set add" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  resource)
  case "${cur1}" in
    relocate)
      COMPREPLY=($(compgen -W "dry-run show run clear" -- ${cur}))
      return 0
      ;;
    failcount)
      COMPREPLY=($(compgen -W "show reset" -- ${cur}))
      return 0
      ;;
    op)
      COMPREPLY=($(compgen -W "defaults remove add" -- ${cur}))
      return 0
      ;;
    group)
      COMPREPLY=($(compgen -W "remove add" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  cluster)
  case "${cur1}" in
    reload)
      COMPREPLY=($(compgen -W "corosync" -- ${cur}))
      return 0
      ;;
    node)
      COMPREPLY=($(compgen -W "remove add" -- ${cur}))
      return 0
      ;;
    uidgid)
      COMPREPLY=($(compgen -W "rm add" -- ${cur}))
      return 0
      ;;
    remote-node)
      COMPREPLY=($(compgen -W "remove add" -- ${cur}))
      return 0
      ;;
    quorum)
      COMPREPLY=($(compgen -W "unblock" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  config)
  case "${cur1}" in
    import-cman)
      COMPREPLY=($(compgen -W "output=<filename>" -- ${cur}))
      return 0
      ;;
    export)
      COMPREPLY=($(compgen -W "pcs-commands pcs-commands-verbose" -- ${cur}))
      return 0
      ;;
    checkpoint)
      COMPREPLY=($(compgen -W "restore view" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  status)
    ;;
  pcsd)
    ;;
  stonith)
  case "${cur1}" in
    level)
      COMPREPLY=($(compgen -W "verify remove clear add" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  node)
    ;;
  property)
    ;;
  acl)
  case "${cur1}" in
    role)
      COMPREPLY=($(compgen -W "unassign create delete assign" -- ${cur}))
      return 0
      ;;
    permission)
      COMPREPLY=($(compgen -W "delete add" -- ${cur}))
      return 0
      ;;
    user)
      COMPREPLY=($(compgen -W "create delete" -- ${cur}))
      return 0
      ;;
    group)
      COMPREPLY=($(compgen -W "create delete" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  *)
  ;;
esac


case "${cur1}" in
  constraint)
    COMPREPLY=($(compgen -W "ref rule location order colocation remove" -- ${cur}))
    return 0
    ;;
  resource)
    COMPREPLY=($(compgen -W "disable relocate clear unclone manage failcount meta list debug-promote create delete debug-monitor ungroup providers update defaults debug-stop enable clone agents ban standards op restart group debug-start debug-demote unmanage move master describe cleanup utilization" -- ${cur}))
    return 0
    ;;
  cluster)
    COMPREPLY=($(compgen -W "disable reload auth node cib-push kill corosync enable sync uidgid edit remote-node stop verify cib setup status start quorum report destroy pcsd-status cib-upgrade" -- ${cur}))
    return 0
    ;;
  config)
    COMPREPLY=($(compgen -W "import-cman backup restore export checkpoint" -- ${cur}))
    return 0
    ;;
  status)
    COMPREPLY=($(compgen -W "nodes groups cluster resources xml pcsd corosync" -- ${cur}))
    return 0
    ;;
  pcsd)
    COMPREPLY=($(compgen -W "clear-auth sync-certificates certkey" -- ${cur}))
    return 0
    ;;
  stonith)
    COMPREPLY=($(compgen -W "level confirm create cleanup delete describe update list fence" -- ${cur}))
    return 0
    ;;
  node)
    COMPREPLY=($(compgen -W "maintenance unstandby unmaintenance standby utilization" -- ${cur}))
    return 0
    ;;
  property)
    COMPREPLY=($(compgen -W "set unset" -- ${cur}))
    return 0
    ;;
  acl)
    COMPREPLY=($(compgen -W "role disable enable permission user group" -- ${cur}))
    return 0
    ;;
  *)
  ;;
esac



    if [ $COMP_CWORD -eq 1 ]; then
        COMPREPLY=( $(compgen -W "resource cluster stonith property acl constraint status config pcsd node" -- $cur) )
    fi
    return 0

    }
    complete -F _pcs pcs
    
