#
# This is the bash auto completion script for the rhc command
#
_rhc()
{
  local cur opts prev
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  if [ $COMP_CWORD -eq 1 ]; then
    if [[ "$cur" == -* ]]; then
      opts="--always-prefix --clean --config --debug --insecure --limit --mock --noprompt --password --raw --rhlogin --server --ssl-ca-file --ssl-client-cert-file --ssl-version --timeout --token"
    elif [ -z $cur ]; then
      opts="account alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-configure app-create app-delete app-deploy app-force-stop app-reload app-restart app-scale-down app-scale-up app-show app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage deployment deployment-activate deployment-list deployment-show domain domain-configure domain-create domain-delete domain-leave domain-list domain-rename domain-show env env-list env-set env-show env-unset git-clone logout member member-add member-list member-remove member-update port-forward scp server setup snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show tail threaddump"
    else
      opts="account account-logout activate-deployment add-alias add-authorization add-cartridge add-member add-sshkey alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert aliases app app-configure app-create app-delete app-deploy app-env app-force-stop app-reload app-restart app-scale-down app-scale-up app-scp app-show app-snapshot app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list authorizations cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage cartridges configure-app configure-domain create-app create-domain delete-all-authorization delete-app delete-authorization delete-cert-alias delete-domain deploy deploy-app deployment deployment-activate deployment-list deployment-show deployments domain domain-configure domain-create domain-delete domain-leave domain-list domain-rename domain-show domains env env-add env-list env-remove env-set env-show env-unset force-stop-app git-clone leave-domain list-alias list-authorization list-cartridge list-deployment list-domain list-env list-member list-sshkey logout member member-add member-list member-remove member-update members port-forward reload-app reload-cartridge remove-alias remove-cartridge remove-member remove-sshkey rename-domain restart-app restart-cartridge restore-snapshot save-snapshot scale-cartridge scale-down-app scale-up-app scp server set-env setup show-app show-cartridge show-deployment show-domain show-env show-sshkey snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show start-app start-cartridge status-cartridge stop-app stop-cartridge storage-cartridge tail threaddump tidy-app unset-env update-cert-alias update-member"
    fi
  else
    prev="${COMP_WORDS[@]:0:COMP_CWORD}"
    SAVE_IFS=$IFS
    IFS=" "
    case "${prev[*]}" in

      "rhc account")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc account logout")
        if [[ "$cur" == -* ]]; then
          opts="--all"
        else
          opts=""
        fi
        ;;

      "rhc account-logout")
        if [[ "$cur" == -* ]]; then
          opts="--all"
        else
          opts=""
        fi
        ;;

      "rhc activate-deployment")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc add-alias")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc add-authorization")
        if [[ "$cur" == -* ]]; then
          opts="--expires-in --note --scopes"
        else
          opts=""
        fi
        ;;

      "rhc add-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --env --gear-size --namespace"
        else
          opts=""
        fi
        ;;

      "rhc add-member")
        if [[ "$cur" == -* ]]; then
          opts="--global --ids --namespace --role --type"
        else
          opts=""
        fi
        ;;

      "rhc add-sshkey")
        if [[ "$cur" == -* ]]; then
          opts="--confirm --content --type"
        else
          opts=""
        fi
        ;;

      "rhc alias")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="add remove update-cert delete-cert list"
        fi
        ;;

      "rhc alias add")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc alias delete-cert")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --namespace"
        else
          opts=""
        fi
        ;;

      "rhc alias list")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc alias remove")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc alias update-cert")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --certificate --namespace --passphrase --private-key"
        else
          opts=""
        fi
        ;;

      "rhc alias-add")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc alias-delete-cert")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --namespace"
        else
          opts=""
        fi
        ;;

      "rhc alias-list")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc alias-remove")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc alias-update-cert")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --certificate --namespace --passphrase --private-key"
        else
          opts=""
        fi
        ;;

      "rhc aliases")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="env snapshot create delete start stop scale-up scale-down force-stop restart reload tidy show deploy configure"
        fi
        ;;

      "rhc app configure")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --auto-deploy --deployment-branch --deployment-type --keep-deployments --namespace --no-auto-deploy"
        else
          opts=""
        fi
        ;;

      "rhc app create")
        if [[ "$cur" == -* ]]; then
          opts="--app --dns --enable-jenkins --env --from-app --from-code --gear-size --git --namespace --no-dns --no-git --no-keys --no-scaling --repo --scaling --type"
        else
          opts=""
        fi
        ;;

      "rhc app delete")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app deploy")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --force-clean-build --hot-deploy --namespace --no-force-clean-build --no-hot-deploy --ref"
        else
          opts=""
        fi
        ;;

      "rhc app env")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app force-stop")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app reload")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app restart")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app scale-down")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app scale-up")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app scp")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --local-path --namespace --remote-path --transfer-direction"
        else
          opts=""
        fi
        ;;

      "rhc app show")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --configuration --gears --namespace --state --verbose"
        else
          opts=""
        fi
        ;;

      "rhc app snapshot")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --deployment --filepath --namespace --ssh"
        else
          opts=""
        fi
        ;;

      "rhc app ssh")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --command --gears --limit --namespace --raw --ssh"
        else
          opts=""
        fi
        ;;

      "rhc app start")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app stop")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app tidy")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-configure")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --auto-deploy --deployment-branch --deployment-type --keep-deployments --namespace --no-auto-deploy"
        else
          opts=""
        fi
        ;;

      "rhc app-create")
        if [[ "$cur" == -* ]]; then
          opts="--app --dns --enable-jenkins --env --from-app --from-code --gear-size --git --namespace --no-dns --no-git --no-keys --no-scaling --repo --scaling --type"
        else
          opts=""
        fi
        ;;

      "rhc app-delete")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-deploy")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --force-clean-build --hot-deploy --namespace --no-force-clean-build --no-hot-deploy --ref"
        else
          opts=""
        fi
        ;;

      "rhc app-env")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-force-stop")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-reload")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-restart")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-scale-down")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-scale-up")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-scp")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --local-path --namespace --remote-path --transfer-direction"
        else
          opts=""
        fi
        ;;

      "rhc app-show")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --configuration --gears --namespace --state --verbose"
        else
          opts=""
        fi
        ;;

      "rhc app-snapshot")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --deployment --filepath --namespace --ssh"
        else
          opts=""
        fi
        ;;

      "rhc app-ssh")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --command --gears --limit --namespace --raw --ssh"
        else
          opts=""
        fi
        ;;

      "rhc app-start")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-stop")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc app-tidy")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc apps")
        if [[ "$cur" == -* ]]; then
          opts="--mine --verbose"
        else
          opts=""
        fi
        ;;

      "rhc authorization")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="list add delete delete-all"
        fi
        ;;

      "rhc authorization add")
        if [[ "$cur" == -* ]]; then
          opts="--expires-in --note --scopes"
        else
          opts=""
        fi
        ;;

      "rhc authorization delete")
        if [[ "$cur" == -* ]]; then
          opts="--auth-token"
        else
          opts=""
        fi
        ;;

      "rhc authorization delete-all")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc authorization list")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc authorization-add")
        if [[ "$cur" == -* ]]; then
          opts="--expires-in --note --scopes"
        else
          opts=""
        fi
        ;;

      "rhc authorization-delete")
        if [[ "$cur" == -* ]]; then
          opts="--auth-token"
        else
          opts=""
        fi
        ;;

      "rhc authorization-delete-all")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc authorization-list")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc authorizations")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc cartridge")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="list add show remove start stop restart status reload scale storage"
        fi
        ;;

      "rhc cartridge add")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --env --gear-size --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge list")
        if [[ "$cur" == -* ]]; then
          opts="--verbose"
        else
          opts=""
        fi
        ;;

      "rhc cartridge reload")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge remove")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --confirm --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge restart")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge scale")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --max --min --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge show")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge start")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge status")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge stop")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge storage")
        if [[ "$cur" == -* ]]; then
          opts="--add --app --application-id --cartridge --force --namespace --remove --set --show"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-add")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --env --gear-size --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-list")
        if [[ "$cur" == -* ]]; then
          opts="--verbose"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-reload")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-remove")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --confirm --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-restart")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-scale")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --max --min --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-show")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-start")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-status")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-stop")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc cartridge-storage")
        if [[ "$cur" == -* ]]; then
          opts="--add --app --application-id --cartridge --force --namespace --remove --set --show"
        else
          opts=""
        fi
        ;;

      "rhc cartridges")
        if [[ "$cur" == -* ]]; then
          opts="--verbose"
        else
          opts=""
        fi
        ;;

      "rhc configure-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --auto-deploy --deployment-branch --deployment-type --keep-deployments --namespace --no-auto-deploy"
        else
          opts=""
        fi
        ;;

      "rhc configure-domain")
        if [[ "$cur" == -* ]]; then
          opts="--allowed-gear-sizes --namespace --no-allowed-gear-sizes"
        else
          opts=""
        fi
        ;;

      "rhc create-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --dns --enable-jenkins --env --from-app --from-code --gear-size --git --namespace --no-dns --no-git --no-keys --no-scaling --repo --scaling --type"
        else
          opts=""
        fi
        ;;

      "rhc create-domain")
        if [[ "$cur" == -* ]]; then
          opts="--allowed-gear-sizes --namespace --no-allowed-gear-sizes"
        else
          opts=""
        fi
        ;;

      "rhc delete-all-authorization")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc delete-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --namespace"
        else
          opts=""
        fi
        ;;

      "rhc delete-authorization")
        if [[ "$cur" == -* ]]; then
          opts="--auth-token"
        else
          opts=""
        fi
        ;;

      "rhc delete-cert-alias")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --namespace"
        else
          opts=""
        fi
        ;;

      "rhc delete-domain")
        if [[ "$cur" == -* ]]; then
          opts="--force --namespace"
        else
          opts=""
        fi
        ;;

      "rhc deploy")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --force-clean-build --hot-deploy --namespace --no-force-clean-build --no-hot-deploy --ref"
        else
          opts=""
        fi
        ;;

      "rhc deploy-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --force-clean-build --hot-deploy --namespace --no-force-clean-build --no-hot-deploy --ref"
        else
          opts=""
        fi
        ;;

      "rhc deployment")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="list show activate"
        fi
        ;;

      "rhc deployment activate")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc deployment list")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc deployment show")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc deployment-activate")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc deployment-list")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc deployment-show")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc deployments")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc domain")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="create rename configure show list delete leave"
        fi
        ;;

      "rhc domain configure")
        if [[ "$cur" == -* ]]; then
          opts="--allowed-gear-sizes --namespace --no-allowed-gear-sizes"
        else
          opts=""
        fi
        ;;

      "rhc domain create")
        if [[ "$cur" == -* ]]; then
          opts="--allowed-gear-sizes --namespace --no-allowed-gear-sizes"
        else
          opts=""
        fi
        ;;

      "rhc domain delete")
        if [[ "$cur" == -* ]]; then
          opts="--force --namespace"
        else
          opts=""
        fi
        ;;

      "rhc domain leave")
        if [[ "$cur" == -* ]]; then
          opts="--namespace"
        else
          opts=""
        fi
        ;;

      "rhc domain list")
        if [[ "$cur" == -* ]]; then
          opts="--ids --mine"
        else
          opts=""
        fi
        ;;

      "rhc domain rename")
        if [[ "$cur" == -* ]]; then
          opts="--namespace"
        else
          opts=""
        fi
        ;;

      "rhc domain show")
        if [[ "$cur" == -* ]]; then
          opts="--namespace"
        else
          opts=""
        fi
        ;;

      "rhc domain-configure")
        if [[ "$cur" == -* ]]; then
          opts="--allowed-gear-sizes --namespace --no-allowed-gear-sizes"
        else
          opts=""
        fi
        ;;

      "rhc domain-create")
        if [[ "$cur" == -* ]]; then
          opts="--allowed-gear-sizes --namespace --no-allowed-gear-sizes"
        else
          opts=""
        fi
        ;;

      "rhc domain-delete")
        if [[ "$cur" == -* ]]; then
          opts="--force --namespace"
        else
          opts=""
        fi
        ;;

      "rhc domain-leave")
        if [[ "$cur" == -* ]]; then
          opts="--namespace"
        else
          opts=""
        fi
        ;;

      "rhc domain-list")
        if [[ "$cur" == -* ]]; then
          opts="--ids --mine"
        else
          opts=""
        fi
        ;;

      "rhc domain-rename")
        if [[ "$cur" == -* ]]; then
          opts="--namespace"
        else
          opts=""
        fi
        ;;

      "rhc domain-show")
        if [[ "$cur" == -* ]]; then
          opts="--namespace"
        else
          opts=""
        fi
        ;;

      "rhc domains")
        if [[ "$cur" == -* ]]; then
          opts="--ids --mine"
        else
          opts=""
        fi
        ;;

      "rhc env")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="add set remove unset list show"
        fi
        ;;

      "rhc env add")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc env list")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace --quotes --table"
        else
          opts=""
        fi
        ;;

      "rhc env remove")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc env set")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc env show")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --env --namespace --quotes --table"
        else
          opts=""
        fi
        ;;

      "rhc env unset")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc env-add")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc env-list")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace --quotes --table"
        else
          opts=""
        fi
        ;;

      "rhc env-remove")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc env-set")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc env-show")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --env --namespace --quotes --table"
        else
          opts=""
        fi
        ;;

      "rhc env-unset")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc force-stop-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc git-clone")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace --repo"
        else
          opts=""
        fi
        ;;

      "rhc leave-domain")
        if [[ "$cur" == -* ]]; then
          opts="--namespace"
        else
          opts=""
        fi
        ;;

      "rhc list-alias")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc list-authorization")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc list-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--verbose"
        else
          opts=""
        fi
        ;;

      "rhc list-deployment")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc list-domain")
        if [[ "$cur" == -* ]]; then
          opts="--ids --mine"
        else
          opts=""
        fi
        ;;

      "rhc list-env")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace --quotes --table"
        else
          opts=""
        fi
        ;;

      "rhc list-member")
        if [[ "$cur" == -* ]]; then
          opts="--all --app --ids --namespace --target"
        else
          opts=""
        fi
        ;;

      "rhc list-sshkey")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc logout")
        if [[ "$cur" == -* ]]; then
          opts="--all"
        else
          opts=""
        fi
        ;;

      "rhc member")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="list add update remove"
        fi
        ;;

      "rhc member add")
        if [[ "$cur" == -* ]]; then
          opts="--global --ids --namespace --role --type"
        else
          opts=""
        fi
        ;;

      "rhc member list")
        if [[ "$cur" == -* ]]; then
          opts="--all --app --ids --namespace --target"
        else
          opts=""
        fi
        ;;

      "rhc member remove")
        if [[ "$cur" == -* ]]; then
          opts="--all --ids --namespace --type"
        else
          opts=""
        fi
        ;;

      "rhc member update")
        if [[ "$cur" == -* ]]; then
          opts="--ids --namespace --role --type"
        else
          opts=""
        fi
        ;;

      "rhc member-add")
        if [[ "$cur" == -* ]]; then
          opts="--global --ids --namespace --role --type"
        else
          opts=""
        fi
        ;;

      "rhc member-list")
        if [[ "$cur" == -* ]]; then
          opts="--all --app --ids --namespace --target"
        else
          opts=""
        fi
        ;;

      "rhc member-remove")
        if [[ "$cur" == -* ]]; then
          opts="--all --ids --namespace --type"
        else
          opts=""
        fi
        ;;

      "rhc member-update")
        if [[ "$cur" == -* ]]; then
          opts="--ids --namespace --role --type"
        else
          opts=""
        fi
        ;;

      "rhc members")
        if [[ "$cur" == -* ]]; then
          opts="--all --app --ids --namespace --target"
        else
          opts=""
        fi
        ;;

      "rhc port-forward")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --gear --namespace"
        else
          opts=""
        fi
        ;;

      "rhc reload-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc reload-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc remove-alias")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc remove-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --confirm --namespace"
        else
          opts=""
        fi
        ;;

      "rhc remove-member")
        if [[ "$cur" == -* ]]; then
          opts="--all --ids --namespace --type"
        else
          opts=""
        fi
        ;;

      "rhc remove-sshkey")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc rename-domain")
        if [[ "$cur" == -* ]]; then
          opts="--namespace"
        else
          opts=""
        fi
        ;;

      "rhc restart-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc restart-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc restore-snapshot")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --filepath --namespace --ssh"
        else
          opts=""
        fi
        ;;

      "rhc save-snapshot")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --deployment --filepath --namespace --ssh"
        else
          opts=""
        fi
        ;;

      "rhc scale-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --max --min --namespace"
        else
          opts=""
        fi
        ;;

      "rhc scale-down-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc scale-up-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc scp")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --local-path --namespace --remote-path --transfer-direction"
        else
          opts=""
        fi
        ;;

      "rhc server")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc set-env")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc setup")
        if [[ "$cur" == -* ]]; then
          opts="--autocomplete --clean --create-token --no-create-token --server"
        else
          opts=""
        fi
        ;;

      "rhc show-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --configuration --gears --namespace --state --verbose"
        else
          opts=""
        fi
        ;;

      "rhc show-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc show-deployment")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc show-domain")
        if [[ "$cur" == -* ]]; then
          opts="--namespace"
        else
          opts=""
        fi
        ;;

      "rhc show-env")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --env --namespace --quotes --table"
        else
          opts=""
        fi
        ;;

      "rhc show-sshkey")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc snapshot")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="save restore"
        fi
        ;;

      "rhc snapshot restore")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --filepath --namespace --ssh"
        else
          opts=""
        fi
        ;;

      "rhc snapshot save")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --deployment --filepath --namespace --ssh"
        else
          opts=""
        fi
        ;;

      "rhc snapshot-restore")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --filepath --namespace --ssh"
        else
          opts=""
        fi
        ;;

      "rhc snapshot-save")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --deployment --filepath --namespace --ssh"
        else
          opts=""
        fi
        ;;

      "rhc ssh")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --command --gears --limit --namespace --raw --ssh"
        else
          opts=""
        fi
        ;;

      "rhc sshkey")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts="list show add remove"
        fi
        ;;

      "rhc sshkey add")
        if [[ "$cur" == -* ]]; then
          opts="--confirm --content --type"
        else
          opts=""
        fi
        ;;

      "rhc sshkey list")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc sshkey remove")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc sshkey show")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc sshkey-add")
        if [[ "$cur" == -* ]]; then
          opts="--confirm --content --type"
        else
          opts=""
        fi
        ;;

      "rhc sshkey-list")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc sshkey-remove")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc sshkey-show")
        if [[ "$cur" == -* ]]; then
          opts=""
        else
          opts=""
        fi
        ;;

      "rhc start-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc start-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc status-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc stop-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc stop-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --cartridge --namespace"
        else
          opts=""
        fi
        ;;

      "rhc storage-cartridge")
        if [[ "$cur" == -* ]]; then
          opts="--add --app --application-id --cartridge --force --namespace --remove --set --show"
        else
          opts=""
        fi
        ;;

      "rhc tail")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --files --gear --namespace --opts"
        else
          opts=""
        fi
        ;;

      "rhc threaddump")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc tidy-app")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --namespace"
        else
          opts=""
        fi
        ;;

      "rhc unset-env")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --confirm --env --namespace"
        else
          opts=""
        fi
        ;;

      "rhc update-cert-alias")
        if [[ "$cur" == -* ]]; then
          opts="--app --application-id --certificate --namespace --passphrase --private-key"
        else
          opts=""
        fi
        ;;

      "rhc update-member")
        if [[ "$cur" == -* ]]; then
          opts="--ids --namespace --role --type"
        else
          opts=""
        fi
        ;;

    esac
    IFS=$SAVE_IFS
  fi

  COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  return 0
}

complete -o default -F _rhc rhc
