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


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


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