
    _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)
    ;;
  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
  
    ;;
  property)
    ;;
  constraint)
    ;;
  node)
    ;;
  cluster)
    ;;
  pcsd)
    ;;
  status)
    ;;
  *)
  ;;
esac


case "${cur2}" in
  stonith)
  case "${cur1}" in
    level)
      COMPREPLY=($(compgen -W "verify clear remove add" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  acl)
  case "${cur1}" in
    group)
      COMPREPLY=($(compgen -W "create delete" -- ${cur}))
      return 0
      ;;
    role)
      COMPREPLY=($(compgen -W "unassign assign create delete" -- ${cur}))
      return 0
      ;;
    permission)
      COMPREPLY=($(compgen -W "delete add" -- ${cur}))
      return 0
      ;;
    user)
      COMPREPLY=($(compgen -W "create delete" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  resource)
  case "${cur1}" in
    op)
      COMPREPLY=($(compgen -W "remove defaults add" -- ${cur}))
      return 0
      ;;
    relocate)
      COMPREPLY=($(compgen -W "dry-run show clear run" -- ${cur}))
      return 0
      ;;
    failcount)
      COMPREPLY=($(compgen -W "reset show" -- ${cur}))
      return 0
      ;;
    group)
      COMPREPLY=($(compgen -W "remove add" -- ${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 "restore view" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  property)
    ;;
  constraint)
  case "${cur1}" in
    location)
      COMPREPLY=($(compgen -W "remove show add" -- ${cur}))
      return 0
      ;;
    rule)
      COMPREPLY=($(compgen -W "remove add" -- ${cur}))
      return 0
      ;;
    order)
      COMPREPLY=($(compgen -W "remove show set" -- ${cur}))
      return 0
      ;;
    colocation)
      COMPREPLY=($(compgen -W "remove show add set" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  node)
    ;;
  cluster)
  case "${cur1}" in
    reload)
      COMPREPLY=($(compgen -W "corosync" -- ${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
      ;;
    node)
      COMPREPLY=($(compgen -W "remove add" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  pcsd)
    ;;
  status)
    ;;
  *)
  ;;
esac


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