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


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


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