
  case "${cmd}" in
    rg)
      opts="!OPTS!"
      if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
        COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
        return 0
      fi
      case "${prev}" in
!CASES!
      esac
      COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
      return 0
      ;;
  esac
}

complete -F _rg -o bashdefault -o default rg
!OPTS!!CASES!
        !FLAG!)
          COMPREPLY=($(compgen -f "${cur}"))
          return 0
          ;;
 
        !FLAG!)
          COMPREPLY=($(compgen -W "!CHOICES!" -- "${cur}"))
          return 0
          ;;
!CHOICES!--!FLAG!-
using namespace System.Management.Automation
using namespace System.Management.Automation.Language

Register-ArgumentCompleter -Native -CommandName 'rg' -ScriptBlock {
  param($wordToComplete, $commandAst, $cursorPosition)
  $commandElements = $commandAst.CommandElements
  $command = @(
    'rg'
    for ($i = 1; $i -lt $commandElements.Count; $i++) {
        $element = $commandElements[$i]
        if ($element -isnot [StringConstantExpressionAst] -or
            $element.StringConstantType -ne [StringConstantType]::BareWord -or
            $element.Value.StartsWith('-')) {
            break
    }
    $element.Value
  }) -join ';'

  $completions = @(switch ($command) {
    'rg' {
!FLAGS!
    }
  })

  $completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
    Sort-Object -Property ListItemText
}
!FLAGS!'''[CompletionResult]::new('!DASH_NAME!', '!NAME!', [CompletionResultType]::ParameterName, '!DOC!')!DASH_NAME!!NAME!!DOC!