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


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


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