#!/usr/bin/env bash

## #ddev-generated
## Description: Enable or disable xhprof
## Usage: xhprof on|off|enable|disable|true|false|toggle|status
## Example: "ddev xhprof" (default is "on"), "ddev xhprof off", "ddev xhprof on", "ddev xhprof toggle", "ddev xhprof status"
## ExecRaw: false
## Flags: []
## AutocompleteTerms: ["on","off","enable","disable","toggle","status"]

if [ $# -eq 0 ]; then
  enable_xhprof
  exit
fi

case $1 in
on | true | enable)
  enable_xhprof
  ;;
off | false | disable)
  disable_xhprof
  ;;
toggle)
  status=$(php -m | grep 'xhprof')
  if [ "${status}" = "xhprof" ]; then
    disable_xhprof
  else
    enable_xhprof
  fi
  ;;
status)
  status=$(php -m | grep 'xhprof')
  if [ "${status}" = "xhprof" ]; then
    result="xhprof is enabled"
  else
    result="xhprof is disabled"
  fi
  echo $result
  ;;
*)
  echo "Invalid argument: $1"
  ;;
esac
