# AUTOMATICALLY GENERATED by https://github.com/tqdm/shtab
# Usage:
# 1) Copy this to somewhere (e.g. ~/.local/share/bash_completion/debsbom).
# 2) Add the following line to your .bashrc:
#    source ~/.local/share/bash_completion/debsbom
# See also: https://github.com/scop/bash-completion/blob/main/doc/configuration.md

_shtab_debsbom_subparsers=(generate merge download source-merge repack export delta trace-path filter sec-scan)

_shtab_debsbom_generate_option_strings=(-h --help -o --out --distro-name --distro-supplier --distro-version --distro-summary --base-distro-vendor --spdx-namespace --cdx-standard --cdx-schema-version --cdx-serialnumber --timestamp --add-meta-data --validate -t --sbom-type -r --root --from-pkglist --distro-arch --with-licenses --recommends-deps --no-recommends-deps --suggests-deps --no-suggests-deps)
_shtab_debsbom_merge_option_strings=(-h --help -o --out --distro-name --distro-supplier --distro-version --distro-summary --base-distro-vendor --spdx-namespace --cdx-standard --cdx-schema-version --cdx-serialnumber --timestamp --add-meta-data --validate -t --sbom-type --omit-roots)
_shtab_debsbom_download_option_strings=(-h --help -t --sbom-type --outdir --sources --binaries --skip-pkgs --resolver)
_shtab_debsbom_source_merge_option_strings=(-h --help -t --sbom-type --compress --apply-patches --mtime --pkgdir --outdir)
_shtab_debsbom_repack_option_strings=(-h --help -t --sbom-type --compress --apply-patches --mtime --dldir --outdir --format --copy --validate --sources --binaries)
_shtab_debsbom_export_option_strings=(-h --help -t --sbom-type --format)
_shtab_debsbom_delta_option_strings=(-h --help -o --out --distro-name --distro-supplier --distro-version --distro-summary --base-distro-vendor --spdx-namespace --cdx-standard --cdx-schema-version --cdx-serialnumber --timestamp --add-meta-data --validate -t --sbom-type)
_shtab_debsbom_trace_path_option_strings=(-h --help -t --sbom-type --format --mode)
_shtab_debsbom_filter_option_strings=(-h --help -t --sbom-type --sources --binaries --validate -p --package)
_shtab_debsbom_sec_scan_option_strings=(-h --help -t --sbom-type --author --default-product --product --db --distro --update-db --filter -f --format --min-urgency --tracker --with-paths-to-root)
_shtab_debsbom_option_strings=(-h --help --version -v --verbose --progress --json --print-completion)

_shtab_debsbom_generate__o_COMPGEN=_shtab_compgen_files
_shtab_debsbom_generate___out_COMPGEN=_shtab_compgen_files
_shtab_debsbom_generate__r_COMPGEN=_shtab_compgen_files
_shtab_debsbom_generate___root_COMPGEN=_shtab_compgen_files
_shtab_debsbom_merge_pos_0_COMPGEN=_shtab_compgen_files
_shtab_debsbom_merge__o_COMPGEN=_shtab_compgen_files
_shtab_debsbom_merge___out_COMPGEN=_shtab_compgen_files
_shtab_debsbom_download_pos_0_COMPGEN=_shtab_compgen_files
_shtab_debsbom_download___outdir_COMPGEN=_shtab_compgen_dirs
_shtab_debsbom_source_merge_pos_0_COMPGEN=_shtab_compgen_files
_shtab_debsbom_source_merge___pkgdir_COMPGEN=_shtab_compgen_dirs
_shtab_debsbom_source_merge___outdir_COMPGEN=_shtab_compgen_dirs
_shtab_debsbom_repack_pos_0_COMPGEN=_shtab_compgen_files
_shtab_debsbom_repack_pos_1_COMPGEN=_shtab_compgen_files
_shtab_debsbom_repack___dldir_COMPGEN=_shtab_compgen_dirs
_shtab_debsbom_repack___outdir_COMPGEN=_shtab_compgen_dirs
_shtab_debsbom_export_pos_0_COMPGEN=_shtab_compgen_files
_shtab_debsbom_export_pos_1_COMPGEN=_shtab_compgen_files
_shtab_debsbom_delta_pos_0_COMPGEN=_shtab_compgen_files
_shtab_debsbom_delta_pos_1_COMPGEN=_shtab_compgen_files
_shtab_debsbom_delta__o_COMPGEN=_shtab_compgen_files
_shtab_debsbom_delta___out_COMPGEN=_shtab_compgen_files
_shtab_debsbom_trace_path_pos_0_COMPGEN=_shtab_compgen_files
_shtab_debsbom_filter_pos_0_COMPGEN=_shtab_compgen_files
_shtab_debsbom_filter_pos_1_COMPGEN=_shtab_compgen_files
_shtab_debsbom_sec_scan_pos_0_COMPGEN=_shtab_compgen_files
_shtab_debsbom_sec_scan___db_COMPGEN=_shtab_compgen_dirs

_shtab_debsbom_generate___base_distro_vendor_choices=(debian ubuntu)
_shtab_debsbom_generate___cdx_standard_choices=(default standard-bom)
_shtab_debsbom_generate___cdx_schema_version_choices=(latest)
_shtab_debsbom_generate__t_choices=(cdx spdx)
_shtab_debsbom_generate___sbom_type_choices=(cdx spdx)
_shtab_debsbom_merge___base_distro_vendor_choices=(debian ubuntu)
_shtab_debsbom_merge___cdx_standard_choices=(default standard-bom)
_shtab_debsbom_merge___cdx_schema_version_choices=(latest)
_shtab_debsbom_merge__t_choices=(cdx spdx)
_shtab_debsbom_merge___sbom_type_choices=(cdx spdx)
_shtab_debsbom_download__t_choices=(cdx spdx)
_shtab_debsbom_download___sbom_type_choices=(cdx spdx)
_shtab_debsbom_download___resolver_choices=(debian-snapshot)
_shtab_debsbom_source_merge__t_choices=(cdx spdx)
_shtab_debsbom_source_merge___sbom_type_choices=(cdx spdx)
_shtab_debsbom_source_merge___compress_choices=(no bzip2 gzip xz zstd lz4)
_shtab_debsbom_repack__t_choices=(cdx spdx)
_shtab_debsbom_repack___sbom_type_choices=(cdx spdx)
_shtab_debsbom_repack___compress_choices=(no bzip2 gzip xz zstd lz4)
_shtab_debsbom_repack___format_choices=(standard-bom standard-bom-package)
_shtab_debsbom_export__t_choices=(cdx spdx)
_shtab_debsbom_export___sbom_type_choices=(cdx spdx)
_shtab_debsbom_export___format_choices=(graphml)
_shtab_debsbom_delta___base_distro_vendor_choices=(debian ubuntu)
_shtab_debsbom_delta___cdx_standard_choices=(default standard-bom)
_shtab_debsbom_delta___cdx_schema_version_choices=(latest)
_shtab_debsbom_delta__t_choices=(cdx spdx)
_shtab_debsbom_delta___sbom_type_choices=(cdx spdx)
_shtab_debsbom_trace_path__t_choices=(cdx spdx)
_shtab_debsbom_trace_path___sbom_type_choices=(cdx spdx)
_shtab_debsbom_trace_path___format_choices=(text json ref dot)
_shtab_debsbom_trace_path___mode_choices=(shortest all-shortest all)
_shtab_debsbom_filter__t_choices=(cdx spdx)
_shtab_debsbom_filter___sbom_type_choices=(cdx spdx)
_shtab_debsbom_sec_scan__t_choices=(cdx spdx)
_shtab_debsbom_sec_scan___sbom_type_choices=(cdx spdx)
_shtab_debsbom_sec_scan___default_product_choices=(component distribution)
_shtab_debsbom_sec_scan__f_choices=(text json sarif vex)
_shtab_debsbom_sec_scan___format_choices=(text json sarif vex)
_shtab_debsbom_sec_scan___min_urgency_choices=(high medium low unimportant end-of-life not-yet-assigned)
_shtab_debsbom_pos_0_choices=(generate merge download source-merge repack export delta trace-path filter sec-scan)
_shtab_debsbom___print_completion_choices=(bash zsh tcsh fish powershell)

_shtab_debsbom_generate__h_nargs=0
_shtab_debsbom_generate___help_nargs=0
_shtab_debsbom_generate___validate_nargs=0
_shtab_debsbom_generate___from_pkglist_nargs=0
_shtab_debsbom_generate___with_licenses_nargs=0
_shtab_debsbom_generate___recommends_deps_nargs=0
_shtab_debsbom_generate___no_recommends_deps_nargs=0
_shtab_debsbom_generate___suggests_deps_nargs=0
_shtab_debsbom_generate___no_suggests_deps_nargs=0
_shtab_debsbom_merge_pos_0_nargs=+
_shtab_debsbom_merge__h_nargs=0
_shtab_debsbom_merge___help_nargs=0
_shtab_debsbom_merge___validate_nargs=0
_shtab_debsbom_merge___omit_roots_nargs=0
_shtab_debsbom_download__h_nargs=0
_shtab_debsbom_download___help_nargs=0
_shtab_debsbom_download___sources_nargs=0
_shtab_debsbom_download___binaries_nargs=0
_shtab_debsbom_source_merge__h_nargs=0
_shtab_debsbom_source_merge___help_nargs=0
_shtab_debsbom_source_merge___apply_patches_nargs=0
_shtab_debsbom_repack__h_nargs=0
_shtab_debsbom_repack___help_nargs=0
_shtab_debsbom_repack___apply_patches_nargs=0
_shtab_debsbom_repack___copy_nargs=0
_shtab_debsbom_repack___validate_nargs=0
_shtab_debsbom_repack___sources_nargs=0
_shtab_debsbom_repack___binaries_nargs=0
_shtab_debsbom_export__h_nargs=0
_shtab_debsbom_export___help_nargs=0
_shtab_debsbom_delta__h_nargs=0
_shtab_debsbom_delta___help_nargs=0
_shtab_debsbom_delta___validate_nargs=0
_shtab_debsbom_trace_path__h_nargs=0
_shtab_debsbom_trace_path___help_nargs=0
_shtab_debsbom_filter__h_nargs=0
_shtab_debsbom_filter___help_nargs=0
_shtab_debsbom_filter___sources_nargs=0
_shtab_debsbom_filter___binaries_nargs=0
_shtab_debsbom_filter___validate_nargs=0
_shtab_debsbom_sec_scan__h_nargs=0
_shtab_debsbom_sec_scan___help_nargs=0
_shtab_debsbom_sec_scan___update_db_nargs=0
_shtab_debsbom_sec_scan___with_paths_to_root_nargs=0
_shtab_debsbom_pos_0_nargs=A...
_shtab_debsbom__h_nargs=0
_shtab_debsbom___help_nargs=0
_shtab_debsbom___version_nargs=0
_shtab_debsbom__v_nargs=0
_shtab_debsbom___verbose_nargs=0
_shtab_debsbom___progress_nargs=0
_shtab_debsbom___json_nargs=0


# $1=COMP_WORDS[1]
_shtab_compgen_files() {
  compgen -f -- $1  # files
}

# $1=COMP_WORDS[1]
_shtab_compgen_dirs() {
  compgen -d -- $1  # recurse into subdirs
}

# $1=COMP_WORDS[1]
_shtab_replace_nonword() {
  echo "${1//[^[:word:]]/_}"
}

# set default values (called for the initial parser & any subparsers)
_set_parser_defaults() {
  local subparsers_var="${prefix}_subparsers[@]"
  sub_parsers=${!subparsers_var-}

  local current_option_strings_var="${prefix}_option_strings[@]"
  current_option_strings=${!current_option_strings_var}

  completed_positional_actions=0

  _set_new_action "pos_$completed_positional_actions" true
}

# $1=action identifier
# $2=positional action (bool)
# set all identifiers for an action's parameters
_set_new_action() {
  current_action="${prefix}_$(_shtab_replace_nonword $1)"

  local current_action_compgen_var=${current_action}_COMPGEN
  current_action_compgen="${!current_action_compgen_var-}"

  local current_action_choices_var="${current_action}_choices[@]"
  current_action_choices="${!current_action_choices_var-}"

  local current_action_nargs_var="${current_action}_nargs"
  if [ -n "${!current_action_nargs_var-}" ]; then
    current_action_nargs="${!current_action_nargs_var}"
  else
    current_action_nargs=1
  fi

  current_action_args_start_index=$(( $word_index + 1 - $pos_only ))

  current_action_is_positional=$2
}

# Notes:
# `COMPREPLY`: what will be rendered after completion is triggered
# `completing_word`: currently typed word to generate completions for
# `${!var}`: evaluates the content of `var` and expand its content as a variable
#     hello="world"
#     x="hello"
#     ${!x} -> ${hello} -> "world"
_shtab_debsbom() {
  local completing_word="${COMP_WORDS[COMP_CWORD]}"
  local previous_word="${COMP_WORDS[COMP_CWORD-1]}"
  local completed_positional_actions
  local current_action
  local current_action_args_start_index
  local current_action_choices
  local current_action_compgen
  local current_action_is_positional
  local current_action_nargs
  local current_option_strings
  local sub_parsers
  COMPREPLY=()

  local prefix=_shtab_debsbom
  local word_index=0
  local pos_only=0 # "--" delimiter not encountered yet
  _set_parser_defaults
  word_index=1

  # determine what arguments are appropriate for the current state
  # of the arg parser
  while [ $word_index -ne $COMP_CWORD ]; do
    local this_word="${COMP_WORDS[$word_index]}"

    if [[ $pos_only = 1 || " $this_word " != " -- " ]]; then
      if [[ -n $sub_parsers && " ${sub_parsers[@]} " == *" $this_word "* ]]; then
        # valid subcommand: add it to the prefix & reset the current action
        prefix="${prefix}_$(_shtab_replace_nonword $this_word)"
        _set_parser_defaults
      fi

      if [[ " ${current_option_strings[@]} " == *" $this_word "* ]]; then
        # a new action should be acquired (due to recognised option string or
        # no more input expected from current action);
        # the next positional action can fill in here
        _set_new_action $this_word false
      fi

      if [[ "$current_action_nargs" != "*" ]] && \
         [[ "$current_action_nargs" != "+" ]] && \
         [[ "$current_action_nargs" != "?" ]] && \
         [[ "$current_action_nargs" != *"..." ]] && \
         (( $word_index + 1 - $current_action_args_start_index - $pos_only >= \
            $current_action_nargs )); then
        $current_action_is_positional && let "completed_positional_actions += 1"
        _set_new_action "pos_$completed_positional_actions" true
      fi
    else
      pos_only=1 # "--" delimiter encountered
    fi

    let "word_index+=1"
  done

  # Generate the completions

  COMPREPLY=()
  if [[ $pos_only = 0 && "$completing_word" == -* &&
        ( -z "$current_action_compgen" || "$current_action_is_positional" = true ) ]]; then
    # optional argument started: use option strings
    while IFS= read -r line; do COMPREPLY+=("$line"); done < <(
      compgen -W "${current_option_strings[*]}" -- "$completing_word")
  elif [[ "$previous_word" =~ ^[0-9\&]*[\<\>]\>?$ ]]; then
    # handle redirection operators
    compopt -o filenames 2>/dev/null || : # bash>=4
    while IFS= read -r line; do COMPREPLY+=("$line"); done < <(compgen -f -- "$completing_word")
  else
    # use choices & compgen
    local action_compgen_word="$completing_word"
    # handle tab-completing in the middle of a line (#248 <- #116)
    [[ -n "$current_action_compgen" && "$completing_word" == -* ]] && action_compgen_word=""
    [ -n "$current_action_compgen" ] && {
      [[ "$current_action_compgen" =~ _(file|dir|glob|FILE|DIR|GLOB)|File|Dir|Glob ]] &&
        compopt -o filenames 2>/dev/null || : # bash>=4
      while IFS= read -r line; do COMPREPLY+=("$line"); done < <(
        "$current_action_compgen" "$action_compgen_word")
    }
    while IFS= read -r line; do COMPREPLY+=("$line"); done < <(
      compgen -W "${current_action_choices[*]}" -- "$completing_word")
  fi

  return 0
}

complete -F _shtab_debsbom debsbom
