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


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


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