# AUTOMATICALLY GENERATED by `shtab`



_shtab_glances_option_strings=('-h' '--help' '--print-completion' '-V' '--version' '-d' '--debug' '-C' '--config' '-P' '--plugins' '--modules-list' '--module-list' '--disable-plugin' '--disable-plugins' '--disable' '--enable-plugin' '--enable-plugins' '--enable' '--disable-process' '--disable-webui' '--light' '--enable-light' '-0' '--disable-irix' '-1' '--percpu' '--per-cpu' '-2' '--disable-left-sidebar' '-3' '--disable-quicklook' '-4' '--full-quicklook' '-5' '--disable-top' '-6' '--meangpu' '--disable-history' '--disable-bold' '--disable-bg' '--enable-irq' '--enable-process-extended' '--disable-separator' '--disable-cursor' '--arrow-keys-sort' '--sort-processes' '--programs' '--program' '--export' '--export-csv-file' '--export-csv-overwrite' '--export-json-file' '--export-graph-path' '--export-process-filter' '-c' '--client' '-s' '--server' '--browser' '--disable-autodiscover' '-p' '--port' '-B' '--bind' '-u' '--username' '--password' '--snmp-community' '--snmp-port' '--snmp-version' '--snmp-user' '--snmp-auth' '--snmp-force' '-t' '--time' '-w' '--webserver' '--enable-mcp' '--mcp-path' '--cached-time' '--stop-after' '--open-web-browser' '-q' '--quiet' '-f' '--process-filter' '--process-focus' '--process-short-name' '--process-long-name' '--stdout' '--stdout-json' '--stdout-csv' '--issue' '--trace-malloc' '--memory-leak' '--api-doc' '--api-restful-doc' '--hide-kernel-threads' '-b' '--byte' '--diskio-show-ramfs' '--diskio-iops' '--diskio-latency' '--fahrenheit' '--fs-free-space' '--sparkline' '--disable-unicode' '--hide-public-info' '--disable-config-exec' '--disable-check-update' '--strftime' '--fetch' '--stdout-fetch' '--fetch-template' '--stdout-fetch-template')

_shtab_glances__C_COMPGEN=_shtab_compgen_files
_shtab_glances___config_COMPGEN=_shtab_compgen_files

_shtab_glances___print_completion_choices=('bash' 'zsh' 'tcsh')
_shtab_glances___sort_processes_choices=('cpu_percent' 'memory_percent' 'username' 'cpu_times' 'io_counters' 'name' 'cpu_num')

_shtab_glances__h_nargs=0
_shtab_glances___help_nargs=0
_shtab_glances__V_nargs=0
_shtab_glances___version_nargs=0
_shtab_glances__d_nargs=0
_shtab_glances___debug_nargs=0
_shtab_glances___modules_list_nargs=0
_shtab_glances___module_list_nargs=0
_shtab_glances___disable_process_nargs=0
_shtab_glances___disable_webui_nargs=0
_shtab_glances___light_nargs=0
_shtab_glances___enable_light_nargs=0
_shtab_glances__0_nargs=0
_shtab_glances___disable_irix_nargs=0
_shtab_glances__1_nargs=0
_shtab_glances___percpu_nargs=0
_shtab_glances___per_cpu_nargs=0
_shtab_glances__2_nargs=0
_shtab_glances___disable_left_sidebar_nargs=0
_shtab_glances__3_nargs=0
_shtab_glances___disable_quicklook_nargs=0
_shtab_glances__4_nargs=0
_shtab_glances___full_quicklook_nargs=0
_shtab_glances__5_nargs=0
_shtab_glances___disable_top_nargs=0
_shtab_glances__6_nargs=0
_shtab_glances___meangpu_nargs=0
_shtab_glances___disable_history_nargs=0
_shtab_glances___disable_bold_nargs=0
_shtab_glances___disable_bg_nargs=0
_shtab_glances___enable_irq_nargs=0
_shtab_glances___enable_process_extended_nargs=0
_shtab_glances___disable_separator_nargs=0
_shtab_glances___disable_cursor_nargs=0
_shtab_glances___arrow_keys_sort_nargs=0
_shtab_glances___programs_nargs=0
_shtab_glances___program_nargs=0
_shtab_glances___export_csv_overwrite_nargs=0
_shtab_glances__s_nargs=0
_shtab_glances___server_nargs=0
_shtab_glances___browser_nargs=0
_shtab_glances___disable_autodiscover_nargs=0
_shtab_glances___username_nargs=0
_shtab_glances___password_nargs=0
_shtab_glances___snmp_force_nargs=0
_shtab_glances__w_nargs=0
_shtab_glances___webserver_nargs=0
_shtab_glances___enable_mcp_nargs=0
_shtab_glances___open_web_browser_nargs=0
_shtab_glances__q_nargs=0
_shtab_glances___quiet_nargs=0
_shtab_glances___process_short_name_nargs=0
_shtab_glances___process_long_name_nargs=0
_shtab_glances___issue_nargs=0
_shtab_glances___trace_malloc_nargs=0
_shtab_glances___memory_leak_nargs=0
_shtab_glances___api_doc_nargs=0
_shtab_glances___api_restful_doc_nargs=0
_shtab_glances___hide_kernel_threads_nargs=0
_shtab_glances__b_nargs=0
_shtab_glances___byte_nargs=0
_shtab_glances___diskio_show_ramfs_nargs=0
_shtab_glances___diskio_iops_nargs=0
_shtab_glances___diskio_latency_nargs=0
_shtab_glances___fahrenheit_nargs=0
_shtab_glances___fs_free_space_nargs=0
_shtab_glances___sparkline_nargs=0
_shtab_glances___disable_unicode_nargs=0
_shtab_glances___hide_public_info_nargs=0
_shtab_glances___disable_config_exec_nargs=0
_shtab_glances___disable_check_update_nargs=0
_shtab_glances___fetch_nargs=0
_shtab_glances___stdout_fetch_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_glances() {
  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_glances
  local word_index=0
  local pos_only=0 # "--" delimeter 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 # "--" delimeter encountered
    fi

    let "word_index+=1"
  done

  # Generate the completions

  if [[ $pos_only = 0 && "${completing_word}" == -* ]]; then
    # optional argument started: use option strings
    COMPREPLY=( $(compgen -W "${current_option_strings[*]}" -- "${completing_word}") )
  elif [[ "${previous_word}" == ">" || "${previous_word}" == ">>" ||
          "${previous_word}" =~ ^[12]">" || "${previous_word}" =~ ^[12]">>" ]]; then
    # handle redirection operators
    COMPREPLY=( $(compgen -f -- "${completing_word}") )
  else
    # use choices & compgen
    local IFS=$'\n' # items may contain spaces, so delimit using newline
    COMPREPLY=( $([ -n "${current_action_compgen}" ] \
                  && "${current_action_compgen}" "${completing_word}") )
    unset IFS
    COMPREPLY+=( $(compgen -W "${current_action_choices[*]}" -- "${completing_word}") )
  fi

  return 0
}

complete -o filenames -F _shtab_glances glances
