#compdef git-sprig

autoload -U is-at-least

_git-sprig() {
    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+[Run as if started in DIR, like \`git -C\`; may be repeated]:DIR:_files' \
'-b+[Commit, branch or tag to use \[default\: the index, as for \`git submodule update\`, or HEAD of a REPOSITORY\]]:REV:_default' \
'--revision=[Commit, branch or tag to use \[default\: the index, as for \`git submodule update\`, or HEAD of a REPOSITORY\]]:REV:_default' \
'--branch=[Commit, branch or tag to use \[default\: the index, as for \`git submodule update\`, or HEAD of a REPOSITORY\]]:REV:_default' \
'--work-tree=[Where submodule paths start in submodule-only mode (default\: the top of the work tree)]:DIR:_files' \
'*--exclude=[Top-level submodule pathspec to exclude; may be repeated]:PATHSPEC:_default' \
'*--recurse-submodules=[Materialize submodules, as by default, like \`git clone --recurse-submodules\`; =PATHSPEC limits the top-level ones and may be repeated]::PATHSPEC:_default' \
'--max-depth=[Levels of submodules to materialize (0 = unlimited)]:N:_default' \
'--remote-url=[Base URL for relative submodule URLs; defaults to the remote, or the repository itself]:URL:_default' \
'*-c+[Set a git configuration value for this run, like \`git -c\`]:KEY=VALUE:_default' \
'*--config=[Set a git configuration value for this run, like \`git -c\`]:KEY=VALUE:_default' \
'--tempdir=[Directory for the temporary repositories]:DIR:_files' \
'-j+[Number of submodules fetched at the same time, 0 for the default \[default\: submodule.fetchJobs, or the number of CPUs up to 8\]]:N:_default' \
'--jobs=[Number of submodules fetched at the same time, 0 for the default \[default\: submodule.fetchJobs, or the number of CPUs up to 8\]]:N:_default' \
'--generate-completions=[Print shell completions, for \`git sprig\` too, and exit]:SHELL:(bash fish zsh)' \
'-f[Replace destinations that are or contain git checkouts, discarding work in them]' \
'--force[Replace destinations that are or contain git checkouts, discarding work in them]' \
'--stage[Replace the submodules in the superproject'\''s index with their files, ready to commit]' \
'--raw[Write files as stored, without .gitattributes conversion]' \
'--no-filters[Write files as stored, without .gitattributes conversion]' \
'(--recurse-submodules)--no-recurse-submodules[Materialize the REPOSITORY alone, without its submodules, as \`git clone\` does]' \
'--no-recursive[Do not recurse into submodules of submodules]' \
'-n[Show what would be fetched without changing anything]' \
'--dry-run[Show what would be fetched without changing anything]' \
'*-q[Only print errors]' \
'*--quiet[Only print errors]' \
'*-v[Also print how each submodule was fetched and written]' \
'*--verbose[Also print how each submodule was fetched and written]' \
'--generate-man[Print the manual page, to install as git-sprig(1), and exit]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
'::repository -- Local or remote repository to materialize completely:_default' \
'::directory -- Required destination for the complete repository tree:_files' \
&& ret=0
}

(( $+functions[_git-sprig_commands] )) ||
_git-sprig_commands() {
    local commands; commands=()
    _describe -t commands 'git-sprig commands' commands "$@"
}

if [ "$funcstack[1]" = "_git-sprig" ]; then
    _git-sprig "$@"
else
    compdef _git-sprig git-sprig
fi
