#compdef vcspull

# AUTOMATICALLY GENERATED by `shtab`


_shtab_vcspull_commands() {
  local _commands=(
    "add:Add a single repository to the configuration."
    "discover:Discover and add repositories from filesystem."
    "fmt:Format vcspull configuration files for consistency."
    "list:List configured repositories."
    "search:Search configured repositories."
    "status:Check status of repositories."
    "sync:Synchronize VCS repositories."
  )
  _describe 'vcspull commands' _commands
}

_shtab_vcspull_options=(
  "(- : *)"{-h,--help}"[show this help message and exit]"
  "(- : *)"{--version,-V}"[show program\'s version number and exit]"
  "--log-level[log level (debug, info, warning, error, critical)]:log_level:"
)

# guard to ensure default positional specs are added only once per session
_shtab_vcspull_defaults_added=0

_shtab_vcspull_add_options=(
  "(- : *)"{-h,--help}"[show this help message and exit]"
  "--name[Override detected repository name when importing from a path]:override_name:"
  "--url[Repository URL to record (overrides detected remotes)]:url:"
  {-f,--file}"[path to config file (default\: \~\/.vcspull.yaml or .\/.vcspull.yaml)]:config:"
  {-w,--workspace,--workspace-root}"[Workspace root directory in config (e.g., \'\~\/projects\/\'). Defaults to the parent directory of the repository path.]:workspace_root_path:"
  {--dry-run,-n}"[Preview changes without writing to config file]"
  "--no-merge[Skip merging duplicate workspace roots before writing]"
  {-y,--yes}"[Automatically confirm interactive prompts]"
  ":Filesystem path to an existing project. The parent directory becomes the workspace unless overridden with --workspace.:"
)

# guard to ensure default positional specs are added only once per session
_shtab_vcspull_add_defaults_added=0

_shtab_vcspull_discover_options=(
  "(- : *)"{-h,--help}"[show this help message and exit]"
  {-f,--file}"[path to config file (default\: \~\/.vcspull.yaml or .\/.vcspull.yaml)]:config:"
  {-w,--workspace,--workspace-root}"[Workspace root directory in config (e.g., \'\~\/projects\/\'). If not specified, uses the scan directory. Applies the workspace root to all discovered repos.]:workspace_root_path:"
  {--recursive,-r}"[Scan directories recursively]"
  {--yes,-y}"[Skip confirmation prompt]"
  {--dry-run,-n}"[Preview changes without writing to config file]"
  "--no-merge[Skip merging duplicate workspace roots before writing]"
  ":Directory to scan for git repositories:"
)

# guard to ensure default positional specs are added only once per session
_shtab_vcspull_discover_defaults_added=0

_shtab_vcspull_fmt_options=(
  "(- : *)"{-h,--help}"[show this help message and exit]"
  {-f,--file}"[path to config file (default\: .vcspull.yaml or \~\/.vcspull.yaml)]:config:"
  {--write,-w}"[Write formatted configuration back to file]"
  "--all[Format all discovered config files (home, config dir, and current dir)]"
  "--no-merge[Do not merge duplicate workspace roots when formatting]"
)

# guard to ensure default positional specs are added only once per session
_shtab_vcspull_fmt_defaults_added=0

_shtab_vcspull_list_options=(
  "(- : *)"{-h,--help}"[show this help message and exit]"
  {-f,--file}"[path to config file (default\: \~\/.vcspull.yaml or .\/.vcspull.yaml)]:config:"
  {-w,--workspace,--workspace-root}"[filter by workspace root directory]:workspace_root:"
  "--tree[display repositories grouped by workspace root]"
  "--json[output as JSON]"
  "--ndjson[output as NDJSON (one JSON per line)]"
  "--color[when to use colors (default\: auto)]:color:(auto always never)"
  "(*)::filter repositories by name pattern (supports fnmatch):"
)

# guard to ensure default positional specs are added only once per session
_shtab_vcspull_list_defaults_added=0

_shtab_vcspull_search_options=(
  "(- : *)"{-h,--help}"[show this help message and exit]"
  {-f,--file}"[path to config file (default\: \~\/.vcspull.yaml or .\/.vcspull.yaml)]:config:"
  {-w,--workspace,--workspace-root}"[filter by workspace root directory]:workspace_root:"
  "*--field[limit unscoped queries to specific fields (name, path, url, workspace). Repeatable or comma-separated.]:fields:"
  {-i,--ignore-case}"[case-insensitive matching]"
  {-S,--smart-case}"[smart case matching (ignore case unless pattern has capitals)]"
  {-F,--fixed-strings}"[treat search terms as literal strings]"
  "--word-regexp[match only whole words]"
  {-v,--invert-match}"[show non-matching repositories]"
  "--any[match if any term matches (default\: all terms)]"
  "--json[output as JSON]"
  "--ndjson[output as NDJSON (one JSON per line)]"
  "--color[when to use colors (default\: auto)]:color:(auto always never)"
  "(*):search query terms (regex by default). Use field prefixes like name\:, path\:, url\:, workspace\:.:"
)

# guard to ensure default positional specs are added only once per session
_shtab_vcspull_search_defaults_added=0

_shtab_vcspull_status_options=(
  "(- : *)"{-h,--help}"[show this help message and exit]"
  {-f,--file}"[path to config file (default\: \~\/.vcspull.yaml or .\/.vcspull.yaml)]:config:"
  {-w,--workspace,--workspace-root}"[filter by workspace root directory]:workspace_root:"
  {--detailed,-d}"[show detailed status information]"
  "--json[output as JSON]"
  "--ndjson[output as NDJSON (one JSON per line)]"
  "--color[when to use colors (default\: auto)]:color:(auto always never)"
  {--no-concurrent,--sequential}"[check repositories sequentially instead of concurrently]"
  "--max-concurrent[maximum concurrent status checks (default\: 32)]:max_concurrent:"
  "(*)::filter repositories by name pattern (supports fnmatch):"
)

# guard to ensure default positional specs are added only once per session
_shtab_vcspull_status_defaults_added=0

_shtab_vcspull_sync_options=(
  "(- : *)"{-h,--help}"[show this help message and exit]"
  {-f,--file}"[path to config file (default\: \~\/.vcspull.yaml or .\/.vcspull.yaml)]:config:_files"
  {-w,--workspace,--workspace-root}"[filter by workspace root directory]:workspace_root:"
  {--dry-run,-n}"[preview what would be synced without making changes]"
  "--json[output as JSON]"
  "--ndjson[output as NDJSON (one JSON per line)]"
  "--color[when to use colors (default\: auto)]:color:(auto always never)"
  {--exit-on-error,-x}"[exit immediately encountering error (when syncing multiple repos)]"
  "--show-unchanged[include repositories that are already up to date]"
  "--summary-only[print only the plan summary line]"
  "--long[show extended details for each repository]"
  "--relative-paths[display repository paths relative to the workspace root]"
  "--fetch[refresh remote tracking information before planning]"
  "--offline[skip network access while planning (overrides --fetch)]"
  "*"{-v,--verbose}"[increase plan verbosity (-vv for maximum detail)]"
  "(*)::patterns \/ terms of repos, accepts globs \/ fnmatch(3):"
)

# guard to ensure default positional specs are added only once per session
_shtab_vcspull_sync_defaults_added=0


_shtab_vcspull() {
  local context state line curcontext="$curcontext" one_or_more='(*)' remainder='(-)*' default='*::: :->vcspull'

  # Add default positional/remainder specs only if none exist, and only once per session
  if (( ! _shtab_vcspull_defaults_added )); then
    if (( ${_shtab_vcspull_options[(I)${(q)one_or_more}*]} +          ${_shtab_vcspull_options[(I)${(q)remainder}*]} +          ${_shtab_vcspull_options[(I)${(q)default}]} == 0 )); then
      _shtab_vcspull_options+=(': :_shtab_vcspull_commands' '*::: :->vcspull')
    fi
    _shtab_vcspull_defaults_added=1
  fi
  _arguments -C -s $_shtab_vcspull_options

  case $state in
    vcspull)
      words=($line[1] "${words[@]}")
      (( CURRENT += 1 ))
      curcontext="${curcontext%:*:*}:_shtab_vcspull-$line[1]:"
      case $line[1] in
        add) _arguments -C -s $_shtab_vcspull_add_options ;;
        discover) _arguments -C -s $_shtab_vcspull_discover_options ;;
        fmt) _arguments -C -s $_shtab_vcspull_fmt_options ;;
        list) _arguments -C -s $_shtab_vcspull_list_options ;;
        search) _arguments -C -s $_shtab_vcspull_search_options ;;
        status) _arguments -C -s $_shtab_vcspull_status_options ;;
        sync) _arguments -C -s $_shtab_vcspull_sync_options ;;
      esac
  esac
}



typeset -A opt_args

if [[ $zsh_eval_context[-1] == eval ]]; then
  # eval/source/. command, register function for later
  compdef _shtab_vcspull -N vcspull
else
  # autoload from fpath, call function directly
  _shtab_vcspull "$@"
fi

