#compdef srgn

autoload -U is-at-least

_srgn() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'--completions=[Print shell completions for the given shell.]:SHELL:(bash elvish fish powershell zsh)' \
'-G+[Glob of files to work on (instead of reading stdin).]:GLOB: ' \
'--glob=[Glob of files to work on (instead of reading stdin).]:GLOB: ' \
'--stdin-override-to=[Override detection heuristics for stdin readability, and force to value.]:STDIN_OVERRIDE_TO:(true false)' \
'--threads=[Number of threads to run processing on, when working with files.]:THREADS: ' \
'*--csharp=[Scope C# code using a prepared query.]:CSHARP:((comments\:"Comments (including XML, inline, doc comments)"
strings\:"Strings (incl. verbatim, interpolated; incl. quotes, except for interpolated)"
usings\:"\`using\` directives (including periods)"
struct\:"\`struct\` definitions (in their entirety)"
enum\:"\`enum\` definitions (in their entirety)"
interface\:"\`interface\` definitions (in their entirety)"
class\:"\`class\` definitions (in their entirety)"
method\:"Method definitions (in their entirety)"
variable-declaration\:"Variable declarations (in their entirety)"
property\:"Property definitions (in their entirety)"
constructor\:"Constructor definitions (in their entirety)"
destructor\:"Destructor definitions (in their entirety)"
field\:"Field definitions on types (in their entirety)"
attribute\:"Attribute names"
identifier\:"Identifier names"))' \
'*--csharp-query=[Scope C# code using a custom tree-sitter query.]:TREE-SITTER-QUERY: ' \
'*--go=[Scope Go code using a prepared query.]:GO:((comments\:"Comments (single- and multi-line)"
strings\:"Strings (interpreted and raw; excluding struct tags)"
imports\:"Imports"
type-def\:"Type definitions"
type-alias\:"Type alias assignments"
struct\:"\`struct\` type definitions"
interface\:"\`interface\` type definitions"
const\:"\`const\` specifications"
var\:"\`var\` specifications"
func\:"\`func\` definitions"
method\:"Method \`func\` definitions (\`func (recv Recv) SomeFunc()\`)"
free-func\:"Free \`func\` definitions (\`func SomeFunc()\`)"
init-func\:"\`func init()\` definitions"
type-params\:"Type parameters (generics)"
defer\:"\`defer\` blocks"
select\:"\`select\` blocks"
go\:"\`go\` blocks"
switch\:"\`switch\` blocks"
labeled\:"Labeled statements"
goto\:"\`goto\` statements"
struct-tags\:"Struct tags"))' \
'*--go-query=[Scope Go code using a custom tree-sitter query.]:TREE-SITTER-QUERY: ' \
'*--hcl=[Scope HashiCorp Configuration Language code using a prepared query.]:HCL:((variable\:"\`variable\` blocks (in their entirety)"
resource\:"\`resource\` blocks (in their entirety)"
data\:"\`data\` blocks (in their entirety)"
output\:"\`output\` blocks (in their entirety)"
provider\:"\`provider\` blocks (in their entirety)"
terraform\:"\`terraform\` blocks (in their entirety)"
locals\:"\`locals\` blocks (in their entirety)"
module\:"\`module\` blocks (in their entirety)"
variables\:"Variable declarations and usages"
resource-names\:"\`resource\` name declarations and usages"
resource-types\:"\`resource\` type declarations and usages"
data-names\:"\`data\` name declarations and usages"
data-sources\:"\`data\` source declarations and usages"
comments\:"Comments"
strings\:"Literal strings"))' \
'*--hcl-query=[Scope HashiCorp Configuration Language code using a custom tree-sitter query.]:TREE-SITTER-QUERY: ' \
'*--python=[Scope Python code using a prepared query.]:PYTHON:((comments\:"Comments"
strings\:"Strings (raw, byte, f-strings; interpolation not included)"
imports\:"Module names in imports (incl. periods; excl. \`import\`/\`from\`/\`as\`/\`*\`)"
doc-strings\:"Docstrings (not including multi-line strings)"
function-names\:"Function names, at the definition site"
function-calls\:"Function calls"
class\:"Class definitions (in their entirety)"
def\:"Function definitions (*all* \`def\` block in their entirety)"
async-def\:"Async function definitions (*all* \`async def\` block in their entirety)"
methods\:"Function definitions inside \`class\` bodies"
class-methods\:"Function definitions decorated as \`classmethod\` (excl. the decorator)"
static-methods\:"Function definitions decorated as \`staticmethod\` (excl. the decorator)"
with\:"\`with\` blocks (in their entirety)"
try\:"\`try\` blocks (in their entirety)"
lambda\:"\`lambda\` statements (in their entirety)"
globals\:"Global, i.e. module-level variables"
variable-identifiers\:"Identifiers for variables (left-hand side of assignments)"
types\:"Types in type hints"))' \
'*--python-query=[Scope Python code using a custom tree-sitter query.]:TREE-SITTER-QUERY: ' \
'*--rust=[Scope Rust code using a prepared query.]:RUST:((comments\:"Comments (line and block styles; excluding doc comments; comment chars incl.)"
doc-comments\:"Doc comments (comment chars included)"
uses\:"Use statements (paths only; excl. \`use\`/\`as\`/\`*\`)"
strings\:"Strings (regular, raw, byte; includes interpolation parts in format strings!)"
attribute\:"Attributes like \`#\[attr\]\`"
struct\:"\`struct\` definitions"
priv-struct\:"\`struct\` definitions not marked \`pub\`"
pub-struct\:"\`struct\` definitions marked \`pub\`"
pub-crate-struct\:"\`struct\` definitions marked \`pub(crate)\`"
pub-self-struct\:"\`struct\` definitions marked \`pub(self)\`"
pub-super-struct\:"\`struct\` definitions marked \`pub(super)\`"
enum\:"\`enum\` definitions"
priv-enum\:"\`enum\` definitions not marked \`pub\`"
pub-enum\:"\`enum\` definitions marked \`pub\`"
pub-crate-enum\:"\`enum\` definitions marked \`pub(crate)\`"
pub-self-enum\:"\`enum\` definitions marked \`pub(self)\`"
pub-super-enum\:"\`enum\` definitions marked \`pub(super)\`"
enum-variant\:"Variant members of \`enum\` definitions"
fn\:"Function definitions"
impl-fn\:"Function definitions inside \`impl\` blocks (associated functions/methods)"
priv-fn\:"Function definitions not marked \`pub\`"
pub-fn\:"Function definitions marked \`pub\`"
pub-crate-fn\:"Function definitions marked \`pub(crate)\`"
pub-self-fn\:"Function definitions marked \`pub(self)\`"
pub-super-fn\:"Function definitions marked \`pub(super)\`"
const-fn\:"Function definitions marked \`const\`"
async-fn\:"Function definitions marked \`async\`"
unsafe-fn\:"Function definitions marked \`unsafe\`"
extern-fn\:"Function definitions marked \`extern\`"
test-fn\:"Function definitions with attributes containing \`test\` (\`#\[test\]\`, \`#\[rstest\]\`, ...)"
trait\:"\`trait\` definitions"
impl\:"\`impl\` blocks"
impl-type\:"\`impl\` blocks for types (\`impl SomeType {}\`)"
impl-trait\:"\`impl\` blocks for traits on types (\`impl SomeTrait for SomeType {}\`)"
mod\:"\`mod\` blocks"
mod-tests\:"\`mod tests\` blocks"
type-def\:"Type definitions (\`struct\`, \`enum\`, \`union\`)"
identifier\:"Identifiers"
type-identifier\:"Identifiers for types"
closure\:"Closure definitions"))' \
'*--rust-query=[Scope Rust code using a custom tree-sitter query.]:TREE-SITTER-QUERY: ' \
'*--typescript=[Scope TypeScript code using a prepared query.]:TYPESCRIPT:((comments\:"Comments"
strings\:"Strings (literal, template)"
imports\:"Imports (module specifiers)"
function\:"Any \`function\` definitions"
async-function\:"\`async function\` definitions"
sync-function\:"Non-\`async function\` definitions"
method\:"Method definitions"
constructor\:"\`constructor\` method definitions"
class\:"\`class\` definitions"
enum\:"\`enum\` definitions"
interface\:"\`interface\` definitions"
try-catch\:"\`try\`/\`catch\`/\`finally\` blocks"
var-decl\:"Variable declarations (\`let\`, \`const\`, \`var\`)"
let\:"\`let\` variable declarations"
const\:"\`const\` variable declarations"
var\:"\`var\` variable declarations"
type-params\:"Type (generic) parameters"
type-alias\:"Type alias declarations"
namespace\:"\`namespace\` blocks"
export\:"\`export\` blocks"))' \
'*--typescript-query=[Scope TypeScript code using a custom tree-sitter query.]:TREE-SITTER-QUERY: ' \
'-u[Uppercase anything in scope.]' \
'--upper[Uppercase anything in scope.]' \
'-l[Lowercase anything in scope.]' \
'--lower[Lowercase anything in scope.]' \
'-t[Titlecase anything in scope.]' \
'--titlecase[Titlecase anything in scope.]' \
'-n[Normalize (Normalization Form D) anything in scope, and throw away marks.]' \
'--normalize[Normalize (Normalization Form D) anything in scope, and throw away marks.]' \
'-g[Perform substitutions on German words, such as '\''Abenteuergruesse'\'' to '\''Abenteuergrüße'\'', for anything in scope.]' \
'--german[Perform substitutions on German words, such as '\''Abenteuergruesse'\'' to '\''Abenteuergrüße'\'', for anything in scope.]' \
'-S[Perform substitutions on symbols, such as '\''!='\'' to '\''≠'\'', '\''->'\'' to '\''→'\'', on anything in scope.]' \
'--symbols[Perform substitutions on symbols, such as '\''!='\'' to '\''≠'\'', '\''->'\'' to '\''→'\'', on anything in scope.]' \
'(-u --upper -l --lower -t --titlecase -n --normalize -g --german -S --symbols)-d[Delete anything in scope.]' \
'(-u --upper -l --lower -t --titlecase -n --normalize -g --german -S --symbols)--delete[Delete anything in scope.]' \
'-s[Squeeze consecutive occurrences of scope into one.]' \
'--squeeze[Squeeze consecutive occurrences of scope into one.]' \
'--squeeze-repeats[Squeeze consecutive occurrences of scope into one.]' \
'--fail-no-files[Fail if working on files (e.g. globbing is requested) but none are found.]' \
'-i[Undo the effects of passed actions, where applicable.]' \
'--invert[Undo the effects of passed actions, where applicable.]' \
'-L[Do not interpret the scope as a regex. Instead, interpret it as a literal string. Will require a scope to be passed.]' \
'--literal-string[Do not interpret the scope as a regex. Instead, interpret it as a literal string. Will require a scope to be passed.]' \
'--fail-any[If anything at all is found to be in scope, fail.]' \
'--fail-none[If nothing is found to be in scope, fail.]' \
'-j[Join (logical '\''OR'\'') multiple language scopes, instead of intersecting them.]' \
'--join-language-scopes[Join (logical '\''OR'\'') multiple language scopes, instead of intersecting them.]' \
'--line-numbers[Prepend line numbers to output.]' \
'--only-matching[Print only matching lines.]' \
'-H[Do not ignore hidden files and directories.]' \
'--hidden[Do not ignore hidden files and directories.]' \
'--gitignored[Do not ignore \`.gitignore\`d files and directories.]' \
'--sorted[Process files in lexicographically sorted order, by file path.]' \
'*-v[Increase log verbosity level.]' \
'*--verbose[Increase log verbosity level.]' \
'--german-prefer-original[When some original version and its replacement are equally legal, prefer the original and do not modify.]' \
'--german-naive[Always perform any possible replacement ('\''ae'\'' -> '\''ä'\'', '\''ss'\'' -> '\''ß'\'', etc.), regardless of legality of the resulting word]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
'::scope -- Scope to apply to, as a regular expression pattern.:' \
'::replace -- Replace anything in scope with this value.:' \
&& ret=0
}

(( $+functions[_srgn_commands] )) ||
_srgn_commands() {
    local commands; commands=()
    _describe -t commands 'srgn commands' commands "$@"
}

if [ "$funcstack[1]" = "_srgn" ]; then
    _srgn "$@"
else
    compdef _srgn srgn
fi
