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


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


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