github.com/ddev/ddev@v1.23.2-0.20240519125000-d824ffe36ff3/pkg/ddevapp/global_dotddev_assets/commands/host/tableplus (about)

     1  #!/bin/bash
     2  
     3  #ddev-generated
     4  # Support for TablePlus, https://tableplus.com/
     5  # This command is available on macOS and WSL2 if TablePlus is installed in the default location.
     6  ## Description: Run tableplus with current project database
     7  ## Usage: tableplus
     8  ## Example: "ddev tableplus"
     9  ## OSTypes: darwin,wsl2
    10  ## HostBinaryExists: /Applications/TablePlus.app,/Applications/Setapp/TablePlus.app,/mnt/c/Program Files/TablePlus/TablePlus.exe
    11  
    12  if [ "${DDEV_PROJECT_STATUS}" != "running" ] && [ -z "$no_recursion" ]; then
    13    echo "Project ${DDEV_PROJECT} is not running, starting it"
    14    ddev start
    15    start_exit_code=$?
    16    if [ $start_exit_code -ne 0 ]; then
    17      exit $start_exit_code
    18    fi
    19    # run this script again, as the environment is updated after "ddev start"
    20    no_recursion=true ddev "$(basename "$0")" "$@"
    21    exit $?
    22  fi
    23  
    24  dbtype=${DDEV_DBIMAGE%:*}
    25  driver=mysql
    26  if [[ $dbtype == "postgres" ]]; then
    27      driver=$dbtype
    28  fi
    29  query="${driver}://db:db@127.0.0.1:${DDEV_HOST_DB_PORT}/db?Enviroment=local&Name=ddev-${DDEV_SITENAME}"
    30  
    31  case $OSTYPE in
    32    "linux-gnu")
    33      "/mnt/c/Program Files/TablePlus/TablePlus.exe" $query >/dev/null &
    34      ;;
    35    "darwin"*)
    36      set -eu -o pipefail
    37      if [ -d "/Applications/Setapp/TablePlus.app" ]; then
    38          open "$query" -a "/Applications/Setapp/TablePlus.app/Contents/MacOS/TablePlus"
    39      else
    40          open "$query" -a "/Applications/TablePlus.app/Contents/MacOS/TablePlus"
    41      fi
    42      ;;
    43  esac