#compdef ast-grep

autoload -U is-at-least

_ast-grep() {
    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[@]}" : \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_ast-grep_commands" \
"*::: :->ast-grep" \
&& ret=0
    case $state in
    (ast-grep)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ast-grep-command-$line[1]:"
        case $line[1] in
            (run)
_arguments "${_arguments_options[@]}" : \
'-p+[AST pattern to match]:PATTERN:_default' \
'--pattern=[AST pattern to match]:PATTERN:_default' \
'--selector=[AST kind to extract sub-part of pattern to match]:KIND:_default' \
'-r+[String to replace the matched AST node]:FIX:_default' \
'--rewrite=[String to replace the matched AST node]:FIX:_default' \
'-l+[The language of the pattern. Supported languages are\: \[Bash, C, Cpp, CSharp, Css, Elixir, Go, Haskell, Html, Java, JavaScript, Json, Kotlin, Lua, Php, Python, Ruby, Rust, Scala, Swift, Tsx, TypeScript, Yaml\]]:LANG:_default' \
'--lang=[The language of the pattern. Supported languages are\: \[Bash, C, Cpp, CSharp, Css, Elixir, Go, Haskell, Html, Java, JavaScript, Json, Kotlin, Lua, Php, Python, Ruby, Rust, Scala, Swift, Tsx, TypeScript, Yaml\]]:LANG:_default' \
'--debug-query=[Print query pattern'\''s tree-sitter AST. Requires lang be set explicitly]' \
'--strictness=[The strictness of the pattern]:STRICTNESS:((cst\:"Match exact all node"
smart\:"Match all node except source trivial nodes"
ast\:"Match only ast nodes"
relaxed\:"Match ast node except comments"
signature\:"Match ast node except comments, without text"))' \
'*--no-ignore=[Do not respect hidden file system or ignore files (.gitignore, .ignore, etc.)]:FILE_TYPE:((hidden\:"Search hidden files and directories. By default, hidden files and directories are skipped"
dot\:"Don'\''t respect .ignore files. This does *not* affect whether ast-grep will ignore files and directories whose names begin with a dot. For that, use --no-ignore hidden"
exclude\:"Don'\''t respect ignore files that are manually configured for the repository such as git'\''s '\''.git/info/exclude'\''"
global\:"Don'\''t respect ignore files that come from "global" sources such as git'\''s \`core.excludesFile\` configuration option (which defaults to \`\$HOME/.config/git/ignore\`)"
parent\:"Don'\''t respect ignore files (.gitignore, .ignore, etc.) in parent directories"
vcs\:"Don'\''t respect version control ignore files (.gitignore, etc.). This implies --no-ignore parent for VCS files. Note that .ignore files will continue to be respected"))' \
'*--globs=[Include or exclude file paths]:GLOBS:_default' \
'-j+[Set the approximate number of threads to use]:NUM:_default' \
'--threads=[Set the approximate number of threads to use]:NUM:_default' \
'(-i --interactive)--json=[Output matches in structured JSON ]' \
'--color=[Controls output color]:WHEN:((auto\:"Try to use colors, but don'\''t force the issue. If the output is piped to another program, or the console isn'\''t available on Windows, or if TERM=dumb, or if \`NO_COLOR\` is defined, for example, then don'\''t use colors"
always\:"Try very hard to emit colors. This includes emitting ANSI colors on Windows if the console API is unavailable (not implemented yet)"
ansi\:"Ansi is like Always, except it never tries to use anything other than emitting ANSI color codes"
never\:"Never emit colors"))' \
'--inspect=[Inspect information for file/rule discovery and scanning]:GRANULARITY:((nothing\:"Do not show any tracing information"
summary\:"Show summary about how many files are scanned and skipped"
entity\:"Show per-file/per-rule tracing information"))' \
'(-C --context)-A+[Show NUM lines after each match]:NUM:_default' \
'(-C --context)--after=[Show NUM lines after each match]:NUM:_default' \
'(-C --context)-B+[Show NUM lines before each match]:NUM:_default' \
'(-C --context)--before=[Show NUM lines before each match]:NUM:_default' \
'-C+[Show NUM lines around each match]:NUM:_default' \
'--context=[Show NUM lines around each match]:NUM:_default' \
'--heading=[Controls whether to print the file name as heading]:WHEN:((auto\:"Print heading for terminal tty but not for piped output"
always\:"Always print heading regardless of output type"
never\:"Never print heading regardless of output type"))' \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--follow[Follow symbolic links]' \
'--stdin[Enable search code from StdIn]' \
'-i[Start interactive edit session]' \
'--interactive[Start interactive edit session]' \
'-U[Apply all rewrite without confirmation if true]' \
'--update-all[Apply all rewrite without confirmation if true]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::paths -- The paths to search. You can provide multiple paths separated by spaces:_files' \
&& ret=0
;;
(scan)
_arguments "${_arguments_options[@]}" : \
'-r+[Scan the codebase with the single rule located at the path RULE_FILE]:RULE_FILE:_files' \
'--rule=[Scan the codebase with the single rule located at the path RULE_FILE]:RULE_FILE:_files' \
'(-r --rule)--inline-rules=[Scan the codebase with a rule defined by the provided RULE_TEXT]:RULE_TEXT:_default' \
'(--json -i --interactive)--format=[Output warning/error messages in GitHub Action format]:FORMAT:(github)' \
'(--json)--report-style=[]:REPORT_STYLE:((rich\:"Output a richly formatted diagnostic, with source code previews"
medium\:"Output a condensed diagnostic, with a line number, severity, message and notes (if any)"
short\:"Output a short diagnostic, with a line number, severity, and message"))' \
'(-r --rule)--filter=[Scan the codebase with rules with ids matching REGEX]:REGEX:_default' \
'*--error=[Set rule severity to error]' \
'*--warning=[Set rule severity to warning]' \
'*--info=[Set rule severity to info]' \
'*--hint=[Set rule severity to hint]' \
'*--off=[Turn off rule]' \
'*--no-ignore=[Do not respect hidden file system or ignore files (.gitignore, .ignore, etc.)]:FILE_TYPE:((hidden\:"Search hidden files and directories. By default, hidden files and directories are skipped"
dot\:"Don'\''t respect .ignore files. This does *not* affect whether ast-grep will ignore files and directories whose names begin with a dot. For that, use --no-ignore hidden"
exclude\:"Don'\''t respect ignore files that are manually configured for the repository such as git'\''s '\''.git/info/exclude'\''"
global\:"Don'\''t respect ignore files that come from "global" sources such as git'\''s \`core.excludesFile\` configuration option (which defaults to \`\$HOME/.config/git/ignore\`)"
parent\:"Don'\''t respect ignore files (.gitignore, .ignore, etc.) in parent directories"
vcs\:"Don'\''t respect version control ignore files (.gitignore, etc.). This implies --no-ignore parent for VCS files. Note that .ignore files will continue to be respected"))' \
'*--globs=[Include or exclude file paths]:GLOBS:_default' \
'-j+[Set the approximate number of threads to use]:NUM:_default' \
'--threads=[Set the approximate number of threads to use]:NUM:_default' \
'(-i --interactive)--json=[Output matches in structured JSON ]' \
'--color=[Controls output color]:WHEN:((auto\:"Try to use colors, but don'\''t force the issue. If the output is piped to another program, or the console isn'\''t available on Windows, or if TERM=dumb, or if \`NO_COLOR\` is defined, for example, then don'\''t use colors"
always\:"Try very hard to emit colors. This includes emitting ANSI colors on Windows if the console API is unavailable (not implemented yet)"
ansi\:"Ansi is like Always, except it never tries to use anything other than emitting ANSI color codes"
never\:"Never emit colors"))' \
'--inspect=[Inspect information for file/rule discovery and scanning]:GRANULARITY:((nothing\:"Do not show any tracing information"
summary\:"Show summary about how many files are scanned and skipped"
entity\:"Show per-file/per-rule tracing information"))' \
'(-C --context)-A+[Show NUM lines after each match]:NUM:_default' \
'(-C --context)--after=[Show NUM lines after each match]:NUM:_default' \
'(-C --context)-B+[Show NUM lines before each match]:NUM:_default' \
'(-C --context)--before=[Show NUM lines before each match]:NUM:_default' \
'-C+[Show NUM lines around each match]:NUM:_default' \
'--context=[Show NUM lines around each match]:NUM:_default' \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--include-metadata[]' \
'--follow[Follow symbolic links]' \
'--stdin[Enable search code from StdIn]' \
'-i[Start interactive edit session]' \
'--interactive[Start interactive edit session]' \
'-U[Apply all rewrite without confirmation if true]' \
'--update-all[Apply all rewrite without confirmation if true]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::paths -- The paths to search. You can provide multiple paths separated by spaces:_files' \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
'-t+[the directories to search test YAML files]:TEST_DIR:_files' \
'--test-dir=[the directories to search test YAML files]:TEST_DIR:_files' \
'--snapshot-dir=[Specify the directory name storing snapshots. Default to __snapshots__]:SNAPSHOT_DIR:_files' \
'-f+[Only run rule test cases that matches REGEX]:REGEX:_default' \
'--filter=[Only run rule test cases that matches REGEX]:REGEX:_default' \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'(-U --update-all)--skip-snapshot-tests[Only check if the test code is valid, without checking rule output. Turn it on when you want to ignore the output of rules. Conflicts with --update-all]' \
'-U[Update the content of all snapshots that have changed in test. Conflicts with --skip-snapshot-tests]' \
'--update-all[Update the content of all snapshots that have changed in test. Conflicts with --skip-snapshot-tests]' \
'-i[Start an interactive review to update snapshots selectively]' \
'--interactive[Start an interactive review to update snapshots selectively]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(new)
_arguments "${_arguments_options[@]}" : \
'-l+[The language of the item to create]:LANG:_default' \
'--lang=[The language of the item to create]:LANG:_default' \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'-y[Accept all default options without interactive input during creation]' \
'--yes[Accept all default options without interactive input during creation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::name -- The id of the item to create:_default' \
":: :_ast-grep__new_commands" \
"*::: :->new" \
&& ret=0

    case $state in
    (new)
        words=($line[2] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ast-grep-new-command-$line[2]:"
        case $line[2] in
            (project)
_arguments "${_arguments_options[@]}" : \
'-l+[The language of the item to create]:LANG:_default' \
'--lang=[The language of the item to create]:LANG:_default' \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'-y[Accept all default options without interactive input during creation]' \
'--yes[Accept all default options without interactive input during creation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::name -- The id of the item to create:_default' \
&& ret=0
;;
(rule)
_arguments "${_arguments_options[@]}" : \
'-l+[The language of the item to create]:LANG:_default' \
'--lang=[The language of the item to create]:LANG:_default' \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'-y[Accept all default options without interactive input during creation]' \
'--yes[Accept all default options without interactive input during creation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::name -- The id of the item to create:_default' \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
'-l+[The language of the item to create]:LANG:_default' \
'--lang=[The language of the item to create]:LANG:_default' \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'-y[Accept all default options without interactive input during creation]' \
'--yes[Accept all default options without interactive input during creation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::name -- The id of the item to create:_default' \
&& ret=0
;;
(util)
_arguments "${_arguments_options[@]}" : \
'-l+[The language of the item to create]:LANG:_default' \
'--lang=[The language of the item to create]:LANG:_default' \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'-y[Accept all default options without interactive input during creation]' \
'--yes[Accept all default options without interactive input during creation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::name -- The id of the item to create:_default' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_ast-grep__new__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ast-grep-new-help-command-$line[1]:"
        case $line[1] in
            (project)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(rule)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(util)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(lsp)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'-h[Print help]' \
'--help[Print help]' \
'::shell -- Output the completion file for given shell. If not provided, shell flavor will be inferred from environment:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(docs)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'--config=[Path to ast-grep root config, default is sgconfig.yml]:CONFIG_FILE:_files' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_ast-grep__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ast-grep-help-command-$line[1]:"
        case $line[1] in
            (run)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(scan)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(new)
_arguments "${_arguments_options[@]}" : \
":: :_ast-grep__help__new_commands" \
"*::: :->new" \
&& ret=0

    case $state in
    (new)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ast-grep-help-new-command-$line[1]:"
        case $line[1] in
            (project)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(rule)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(test)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(util)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(lsp)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(docs)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_ast-grep_commands] )) ||
_ast-grep_commands() {
    local commands; commands=(
'run:Run one time search or rewrite in command line. (default command)' \
'scan:Scan and rewrite code by configuration' \
'test:Test ast-grep rules' \
'new:Create new ast-grep project or items like rules/tests' \
'lsp:Start language server' \
'completions:Generate shell completion script' \
'docs:Generate rule docs for current configuration. (Not Implemented Yet)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ast-grep commands' commands "$@"
}
(( $+functions[_ast-grep__completions_commands] )) ||
_ast-grep__completions_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep completions commands' commands "$@"
}
(( $+functions[_ast-grep__docs_commands] )) ||
_ast-grep__docs_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep docs commands' commands "$@"
}
(( $+functions[_ast-grep__help_commands] )) ||
_ast-grep__help_commands() {
    local commands; commands=(
'run:Run one time search or rewrite in command line. (default command)' \
'scan:Scan and rewrite code by configuration' \
'test:Test ast-grep rules' \
'new:Create new ast-grep project or items like rules/tests' \
'lsp:Start language server' \
'completions:Generate shell completion script' \
'docs:Generate rule docs for current configuration. (Not Implemented Yet)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ast-grep help commands' commands "$@"
}
(( $+functions[_ast-grep__help__completions_commands] )) ||
_ast-grep__help__completions_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help completions commands' commands "$@"
}
(( $+functions[_ast-grep__help__docs_commands] )) ||
_ast-grep__help__docs_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help docs commands' commands "$@"
}
(( $+functions[_ast-grep__help__help_commands] )) ||
_ast-grep__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help help commands' commands "$@"
}
(( $+functions[_ast-grep__help__lsp_commands] )) ||
_ast-grep__help__lsp_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help lsp commands' commands "$@"
}
(( $+functions[_ast-grep__help__new_commands] )) ||
_ast-grep__help__new_commands() {
    local commands; commands=(
'project:Create an new project by scaffolding' \
'rule:Create a new rule' \
'test:Create a new test case' \
'util:Create a new global utility rule' \
    )
    _describe -t commands 'ast-grep help new commands' commands "$@"
}
(( $+functions[_ast-grep__help__new__project_commands] )) ||
_ast-grep__help__new__project_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help new project commands' commands "$@"
}
(( $+functions[_ast-grep__help__new__rule_commands] )) ||
_ast-grep__help__new__rule_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help new rule commands' commands "$@"
}
(( $+functions[_ast-grep__help__new__test_commands] )) ||
_ast-grep__help__new__test_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help new test commands' commands "$@"
}
(( $+functions[_ast-grep__help__new__util_commands] )) ||
_ast-grep__help__new__util_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help new util commands' commands "$@"
}
(( $+functions[_ast-grep__help__run_commands] )) ||
_ast-grep__help__run_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help run commands' commands "$@"
}
(( $+functions[_ast-grep__help__scan_commands] )) ||
_ast-grep__help__scan_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help scan commands' commands "$@"
}
(( $+functions[_ast-grep__help__test_commands] )) ||
_ast-grep__help__test_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep help test commands' commands "$@"
}
(( $+functions[_ast-grep__lsp_commands] )) ||
_ast-grep__lsp_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep lsp commands' commands "$@"
}
(( $+functions[_ast-grep__new_commands] )) ||
_ast-grep__new_commands() {
    local commands; commands=(
'project:Create an new project by scaffolding' \
'rule:Create a new rule' \
'test:Create a new test case' \
'util:Create a new global utility rule' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ast-grep new commands' commands "$@"
}
(( $+functions[_ast-grep__new__help_commands] )) ||
_ast-grep__new__help_commands() {
    local commands; commands=(
'project:Create an new project by scaffolding' \
'rule:Create a new rule' \
'test:Create a new test case' \
'util:Create a new global utility rule' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ast-grep new help commands' commands "$@"
}
(( $+functions[_ast-grep__new__help__help_commands] )) ||
_ast-grep__new__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep new help help commands' commands "$@"
}
(( $+functions[_ast-grep__new__help__project_commands] )) ||
_ast-grep__new__help__project_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep new help project commands' commands "$@"
}
(( $+functions[_ast-grep__new__help__rule_commands] )) ||
_ast-grep__new__help__rule_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep new help rule commands' commands "$@"
}
(( $+functions[_ast-grep__new__help__test_commands] )) ||
_ast-grep__new__help__test_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep new help test commands' commands "$@"
}
(( $+functions[_ast-grep__new__help__util_commands] )) ||
_ast-grep__new__help__util_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep new help util commands' commands "$@"
}
(( $+functions[_ast-grep__new__project_commands] )) ||
_ast-grep__new__project_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep new project commands' commands "$@"
}
(( $+functions[_ast-grep__new__rule_commands] )) ||
_ast-grep__new__rule_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep new rule commands' commands "$@"
}
(( $+functions[_ast-grep__new__test_commands] )) ||
_ast-grep__new__test_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep new test commands' commands "$@"
}
(( $+functions[_ast-grep__new__util_commands] )) ||
_ast-grep__new__util_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep new util commands' commands "$@"
}
(( $+functions[_ast-grep__run_commands] )) ||
_ast-grep__run_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep run commands' commands "$@"
}
(( $+functions[_ast-grep__scan_commands] )) ||
_ast-grep__scan_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep scan commands' commands "$@"
}
(( $+functions[_ast-grep__test_commands] )) ||
_ast-grep__test_commands() {
    local commands; commands=()
    _describe -t commands 'ast-grep test commands' commands "$@"
}

if [ "$funcstack[1]" = "_ast-grep" ]; then
    _ast-grep "$@"
else
    compdef _ast-grep ast-grep
fi
