# This script was generated by crazy-complete.
# crazy-complete: A tool that creates robust and reliable autocompletion scripts for Bash, Fish and Zsh.
# For more information, visit: https://github.com/crazy-complete/crazy-complete

_nbfc_parse_commandline() {
  POSITIONALS=()
  END_OF_OPTIONS=0
  POSITIONAL_NUM=0

  local cmd="${words[0]}" argi arg i char trailing_chars

  for ((argi=1; argi < ${#words[@]} - 1; ++argi)); do
    arg="${words[argi]}"

    case "$arg" in
      --)
        END_OF_OPTIONS=1
        for ((++argi; argi < ${#words[@]}; ++argi)); do
          POSITIONALS[POSITIONAL_NUM++]="${words[argi]}"
        done
        break;;
      -)
        POSITIONALS[POSITIONAL_NUM++]="-";;
      -*)
        case "$cmd" in 'nbfc update')
          case "$arg" in
            --parallel)
              OPT_parallel+=("${words[++argi]}")
              continue;;
            --parallel=*)
              OPT_parallel+=("${arg#*=}")
              continue;;
            --quiet)
              OPT_quiet+=(_OPT_ISSET_)
              continue;;
          esac
        esac

        case "$cmd" in 'nbfc sensors set')
          case "$arg" in
            --fan)
              OPT_fan+=("${words[++argi]}")
              continue;;
            --fan=*)
              OPT_fan+=("${arg#*=}")
              continue;;
            --algorithm)
              OPT_algorithm+=("${words[++argi]}")
              continue;;
            --algorithm=*)
              OPT_algorithm+=("${arg#*=}")
              continue;;
            --sensor)
              OPT_sensor+=("${words[++argi]}")
              continue;;
            --sensor=*)
              OPT_sensor+=("${arg#*=}")
              continue;;
            --force)
              OPT_force+=(_OPT_ISSET_)
              continue;;
          esac
        esac

        case "$cmd" in 'nbfc set')
          case "$arg" in
            --auto)
              OPT_auto+=(_OPT_ISSET_)
              continue;;
            --speed)
              OPT_speed+=("${words[++argi]}")
              continue;;
            --speed=*)
              OPT_speed+=("${arg#*=}")
              continue;;
            --fan)
              OPT_fan+=("${words[++argi]}")
              continue;;
            --fan=*)
              OPT_fan+=("${arg#*=}")
              continue;;
          esac
        esac

        case "$cmd" in 'nbfc config')
          case "$arg" in
            --list)
              OPT_list+=(_OPT_ISSET_)
              continue;;
            --set)
              OPT_set+=("${words[++argi]}")
              continue;;
            --set=*)
              OPT_set+=("${arg#*=}")
              continue;;
            --apply)
              OPT_apply+=("${words[++argi]}")
              continue;;
            --apply=*)
              OPT_apply+=("${arg#*=}")
              continue;;
            --recommend)
              OPT_recommend+=(_OPT_ISSET_)
              continue;;
          esac
        esac

        case "$cmd" in 'nbfc status')
          case "$arg" in
            --all)
              OPT_all+=(_OPT_ISSET_)
              continue;;
            --service)
              OPT_service+=(_OPT_ISSET_)
              continue;;
            --fan)
              OPT_fan+=("${words[++argi]}")
              continue;;
            --fan=*)
              OPT_fan+=("${arg#*=}")
              continue;;
            --watch)
              OPT_watch+=("${words[++argi]}")
              continue;;
            --watch=*)
              OPT_watch+=("${arg#*=}")
              continue;;
          esac
        esac

        case "$cmd" in 'nbfc restart')
          case "$arg" in
            --read-only)
              OPT_read_only+=(_OPT_ISSET_)
              continue;;
          esac
        esac

        case "$cmd" in 'nbfc start')
          case "$arg" in
            --read-only)
              OPT_read_only+=(_OPT_ISSET_)
              continue;;
          esac
        esac

        case "$cmd" in nbfc)
          case "$arg" in
            --help)
              OPT_help+=(_OPT_ISSET_)
              continue;;
            --version)
              OPT_version+=(_OPT_ISSET_)
              continue;;
          esac
        esac
        for ((i=1; i < ${#arg}; ++i)); do
          char="${arg:$i:1}"
          trailing_chars="${arg:$((i + 1))}"
          case "$cmd" in 'nbfc update')
            case "$char" in
              p)
                if [[ -n "$trailing_chars" ]]
                then OPT_parallel+=("$trailing_chars")
                else OPT_parallel+=("${words[++argi]}")
                fi
                continue 2;;
              q)
                OPT_quiet+=(_OPT_ISSET_);;
            esac
          esac

          case "$cmd" in 'nbfc sensors set')
            case "$char" in
              f)
                if [[ -n "$trailing_chars" ]]
                then OPT_fan+=("$trailing_chars")
                else OPT_fan+=("${words[++argi]}")
                fi
                continue 2;;
              a)
                if [[ -n "$trailing_chars" ]]
                then OPT_algorithm+=("$trailing_chars")
                else OPT_algorithm+=("${words[++argi]}")
                fi
                continue 2;;
              s)
                if [[ -n "$trailing_chars" ]]
                then OPT_sensor+=("$trailing_chars")
                else OPT_sensor+=("${words[++argi]}")
                fi
                continue 2;;
            esac
          esac

          case "$cmd" in 'nbfc set')
            case "$char" in
              a)
                OPT_auto+=(_OPT_ISSET_);;
              s)
                if [[ -n "$trailing_chars" ]]
                then OPT_speed+=("$trailing_chars")
                else OPT_speed+=("${words[++argi]}")
                fi
                continue 2;;
              f)
                if [[ -n "$trailing_chars" ]]
                then OPT_fan+=("$trailing_chars")
                else OPT_fan+=("${words[++argi]}")
                fi
                continue 2;;
            esac
          esac

          case "$cmd" in 'nbfc config')
            case "$char" in
              l)
                OPT_list+=(_OPT_ISSET_);;
              s)
                if [[ -n "$trailing_chars" ]]
                then OPT_set+=("$trailing_chars")
                else OPT_set+=("${words[++argi]}")
                fi
                continue 2;;
              a)
                if [[ -n "$trailing_chars" ]]
                then OPT_apply+=("$trailing_chars")
                else OPT_apply+=("${words[++argi]}")
                fi
                continue 2;;
              r)
                OPT_recommend+=(_OPT_ISSET_);;
            esac
          esac

          case "$cmd" in 'nbfc status')
            case "$char" in
              a)
                OPT_all+=(_OPT_ISSET_);;
              s)
                OPT_service+=(_OPT_ISSET_);;
              f)
                if [[ -n "$trailing_chars" ]]
                then OPT_fan+=("$trailing_chars")
                else OPT_fan+=("${words[++argi]}")
                fi
                continue 2;;
              w)
                if [[ -n "$trailing_chars" ]]
                then OPT_watch+=("$trailing_chars")
                else OPT_watch+=("${words[++argi]}")
                fi
                continue 2;;
            esac
          esac

          case "$cmd" in 'nbfc restart')
            case "$char" in
              r)
                OPT_read_only+=(_OPT_ISSET_);;
            esac
          esac

          case "$cmd" in 'nbfc start')
            case "$char" in
              r)
                OPT_read_only+=(_OPT_ISSET_);;
            esac
          esac

          case "$cmd" in nbfc)
            case "$char" in
              h)
                OPT_help+=(_OPT_ISSET_);;
            esac
          esac
        done;;
      *)
        POSITIONALS[POSITIONAL_NUM++]="$arg"
        if (( POSITIONAL_NUM == 2 )); then
          case "$arg" in
            list)
              cmd+=" list";;
            show)
              cmd+=" show";;
            set)
              cmd+=" set";;
            *) cmd+=" $arg";;
          esac
        fi

        if (( POSITIONAL_NUM == 1 )); then
          case "$arg" in
            start)
              cmd+=" start";;
            stop)
              cmd+=" stop";;
            restart)
              cmd+=" restart";;
            status)
              cmd+=" status";;
            config)
              cmd+=" config";;
            set)
              cmd+=" set";;
            sensors)
              cmd+=" sensors";;
            update)
              cmd+=" update";;
            wait-for-hwmon)
              cmd+=" wait-for-hwmon";;
            get-model-name)
              cmd+=" get-model-name";;
            warranty)
              cmd+=" warranty";;
            donate)
              cmd+=" donate";;
            help)
              cmd+=" help";;
            *) cmd+=" $arg";;
          esac
        fi
        ;;
    esac
  done

  for ((; argi < ${#words[@]}; ++argi)); do
    arg="${words[$argi]}"

    case "$arg" in
      -) POSITIONALS[POSITIONAL_NUM++]="$arg";;
      -*);;
      *) POSITIONALS[POSITIONAL_NUM++]="$arg";;
    esac
  done
}

_nbfc_exec() {
  local item desc

  while IFS=$'\t' read -r item desc; do
    if [[ "$item" == "$cur"* ]]; then
      COMPREPLY+=("$(printf '%q' "$item")")
    fi
  done < <(eval "$1")
}

_nbfc_prefix_compreply() {
  local i=0 prefix="$1"
  for ((i=0; i < ${#COMPREPLY[@]}; ++i)); do
    COMPREPLY[i]="$prefix${COMPREPLY[i]}"
  done
}

_nbfc() {
  local cur prev words cword split
  _init_completion -n = || return

  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_help OPT_version

  _nbfc_parse_commandline

  local COMP_WORDBREAKS=''

  if (( 0 < POSITIONAL_NUM )); then
    case "${POSITIONALS[0]}" in
      start) _nbfc_start && return 0 || return 1;;
      stop) _nbfc_stop && return 0 || return 1;;
      restart) _nbfc_restart && return 0 || return 1;;
      status) _nbfc_status && return 0 || return 1;;
      config) _nbfc_config && return 0 || return 1;;
      set) _nbfc_set && return 0 || return 1;;
      sensors) _nbfc_sensors && return 0 || return 1;;
      update) _nbfc_update && return 0 || return 1;;
      wait-for-hwmon) _nbfc_wait_for_hwmon && return 0 || return 1;;
      get-model-name) _nbfc_get_model_name && return 0 || return 1;;
      warranty) _nbfc_warranty && return 0 || return 1;;
      donate) _nbfc_donate && return 0 || return 1;;
      help) _nbfc_help && return 0 || return 1;;
    esac
  fi

  if (( ! END_OF_OPTIONS )) && [[ "$cur" = -* ]]; then
    local -a opts=()
    (( ! ${#OPT_help} )) && opts+=(-h --help)
    (( ! ${#OPT_version} )) && opts+=(--version)
    COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    return 1
  fi

  test "$POSITIONAL_NUM" -eq 1 && {
    COMPREPLY=($(compgen -W 'start stop restart status config set sensors update wait-for-hwmon get-model-name warranty donate help' -- "$cur"))
    return 0;
  }

  return 1
}

_nbfc_start() {
  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_read_only OPT_help OPT_version

  _nbfc_parse_commandline

  local COMP_WORDBREAKS=''

  if (( ! END_OF_OPTIONS )) && [[ "$cur" = -* ]]; then
    local -a opts=()
    (( ! ${#OPT_read_only} )) && opts+=(-r --read-only)
    COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    return 1
  fi

  return 1
}

_nbfc_stop() {
  return 0
}

_nbfc_restart() {
  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_read_only OPT_help OPT_version

  _nbfc_parse_commandline

  local COMP_WORDBREAKS=''

  if (( ! END_OF_OPTIONS )) && [[ "$cur" = -* ]]; then
    local -a opts=()
    (( ! ${#OPT_read_only} )) && opts+=(-r --read-only)
    COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    return 1
  fi

  return 1
}

_nbfc_status() {
  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_all OPT_service OPT_fan OPT_watch OPT_help OPT_version

  _nbfc_parse_commandline

  local COMP_WORDBREAKS=''

  __complete_option() {
    local opt="$1" cur="$2" mode="$3"

    case "$opt" in
      --fan|-f)
        _nbfc_exec 'nbfc complete-fans'
        return 0;;
      --watch|-w)
        return 0;;
    esac

    return 1
  }

  case "$prev" in
    --*)
      __complete_option "$prev" "$cur" WITHOUT_OPTIONALS && return 0;;
    -*)
      case "$prev" in -*([ash])[fw])
        __complete_option "-${prev: -1}" "$cur" WITHOUT_OPTIONALS && return 0
      esac;;
  esac

  case "$cur" in
    --*=*)
      __complete_option "${cur%%=*}" "${cur#*=}" WITH_OPTIONALS && return 0;;
    -*=*);;
    --*);;
    -*)
        local i
        for ((i=2; i <= ${#cur}; ++i)); do
          local pre="${cur:0:$i}" value="${cur:$i}"
          __complete_option "-${pre: -1}" "$value" WITH_OPTIONALS && {
            _nbfc_prefix_compreply "$pre"
            return 0
          }
        done;;
  esac

  if (( ! END_OF_OPTIONS )) && [[ "$cur" = -* ]]; then
    local -a opts=()
    (( ! ${#OPT_service} && ! ${#OPT_fan} && ! ${#OPT_all} )) && opts+=(-a --all)
    (( ! ${#OPT_all} && ! ${#OPT_fan} && ! ${#OPT_service} )) && opts+=(-s --service)
    (( ! ${#OPT_all} && ! ${#OPT_service} && ! ${#OPT_fan} )) && opts+=(-f --fan=)
    (( ! ${#OPT_watch} )) && opts+=(-w --watch=)
    COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    return 1
  fi

  return 1
}

_nbfc_config() {
  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_list OPT_set OPT_apply OPT_recommend OPT_help OPT_version

  _nbfc_parse_commandline

  local COMP_WORDBREAKS=''

  __complete_option() {
    local opt="$1" cur="$2" mode="$3"

    case "$opt" in
      --set|-s|--apply|-a)
        builtin pushd /usr/share/nbfc/configs &>/dev/null && {
          _filedir
          builtin popd &>/dev/null
        }
        return 0;;
    esac

    return 1
  }

  case "$prev" in
    --*)
      __complete_option "$prev" "$cur" WITHOUT_OPTIONALS && return 0;;
    -*)
      case "$prev" in -*([lrh])[sa])
        __complete_option "-${prev: -1}" "$cur" WITHOUT_OPTIONALS && return 0
      esac;;
  esac

  case "$cur" in
    --*=*)
      __complete_option "${cur%%=*}" "${cur#*=}" WITH_OPTIONALS && return 0;;
    -*=*);;
    --*);;
    -*)
        local i
        for ((i=2; i <= ${#cur}; ++i)); do
          local pre="${cur:0:$i}" value="${cur:$i}"
          __complete_option "-${pre: -1}" "$value" WITH_OPTIONALS && {
            _nbfc_prefix_compreply "$pre"
            return 0
          }
        done;;
  esac

  if (( ! END_OF_OPTIONS )) && [[ "$cur" = -* ]]; then
    local -a opts=()
    (( ! ${#OPT_set} && ! ${#OPT_apply} && ! ${#OPT_recommend} && ! ${#OPT_list} )) && opts+=(-l --list)
    (( ! ${#OPT_list} && ! ${#OPT_apply} && ! ${#OPT_recommend} && ! ${#OPT_set} )) && opts+=(-s --set=)
    (( ! ${#OPT_list} && ! ${#OPT_set} && ! ${#OPT_recommend} && ! ${#OPT_apply} )) && opts+=(-a --apply=)
    (( ! ${#OPT_list} && ! ${#OPT_set} && ! ${#OPT_apply} && ! ${#OPT_recommend} )) && opts+=(-r --recommend)
    COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    return 1
  fi

  return 1
}

_nbfc_set() {
  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_auto OPT_speed OPT_fan OPT_help OPT_version

  _nbfc_parse_commandline

  local COMP_WORDBREAKS=''

  __complete_option() {
    local opt="$1" cur="$2" mode="$3"

    case "$opt" in
      --speed|-s)
        return 0;;
      --fan|-f)
        _nbfc_exec 'nbfc complete-fans'
        return 0;;
    esac

    return 1
  }

  case "$prev" in
    --*)
      __complete_option "$prev" "$cur" WITHOUT_OPTIONALS && return 0;;
    -*)
      case "$prev" in -*([ah])[sf])
        __complete_option "-${prev: -1}" "$cur" WITHOUT_OPTIONALS && return 0
      esac;;
  esac

  case "$cur" in
    --*=*)
      __complete_option "${cur%%=*}" "${cur#*=}" WITH_OPTIONALS && return 0;;
    -*=*);;
    --*);;
    -*)
        local i
        for ((i=2; i <= ${#cur}; ++i)); do
          local pre="${cur:0:$i}" value="${cur:$i}"
          __complete_option "-${pre: -1}" "$value" WITH_OPTIONALS && {
            _nbfc_prefix_compreply "$pre"
            return 0
          }
        done;;
  esac

  if (( ! END_OF_OPTIONS )) && [[ "$cur" = -* ]]; then
    local -a opts=()
    (( ! ${#OPT_speed} && ! ${#OPT_auto} )) && opts+=(-a --auto)
    (( ! ${#OPT_auto} && ! ${#OPT_speed} )) && opts+=(-s --speed=)
    (( ! ${#OPT_fan} )) && opts+=(-f --fan=)
    COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    return 1
  fi

  return 1
}

_nbfc_sensors() {
  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_help OPT_version

  _nbfc_parse_commandline

  local COMP_WORDBREAKS=''

  if (( 1 < POSITIONAL_NUM )); then
    case "${POSITIONALS[1]}" in
      list) _nbfc_sensors_list && return 0 || return 1;;
      show) _nbfc_sensors_show && return 0 || return 1;;
      set) _nbfc_sensors_set && return 0 || return 1;;
    esac
  fi

  test "$POSITIONAL_NUM" -eq 2 && {
    COMPREPLY=($(compgen -W 'list show set' -- "$cur"))
    return 0;
  }

  return 1
}

_nbfc_sensors_list() {
  return 0
}

_nbfc_sensors_show() {
  return 0
}

_nbfc_sensors_set() {
  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_fan OPT_algorithm OPT_sensor OPT_force OPT_help OPT_version

  _nbfc_parse_commandline

  local COMP_WORDBREAKS=''

  __complete_option() {
    local opt="$1" cur="$2" mode="$3"

    case "$opt" in
      --fan|-f)
        _nbfc_exec 'nbfc complete-fans'
        return 0;;
      --algorithm|-a)
        COMPREPLY=($(compgen -W 'Average Min Max' -- "$cur"))
        return 0;;
      --sensor|-s)
        _nbfc_exec 'nbfc complete-sensors'
        return 0;;
    esac

    return 1
  }

  case "$prev" in
    --*)
      __complete_option "$prev" "$cur" WITHOUT_OPTIONALS && return 0;;
    -*)
      case "$prev" in -*([h])[fas])
        __complete_option "-${prev: -1}" "$cur" WITHOUT_OPTIONALS && return 0
      esac;;
  esac

  case "$cur" in
    --*=*)
      __complete_option "${cur%%=*}" "${cur#*=}" WITH_OPTIONALS && return 0;;
    -*=*);;
    --*);;
    -*)
        local i
        for ((i=2; i <= ${#cur}; ++i)); do
          local pre="${cur:0:$i}" value="${cur:$i}"
          __complete_option "-${pre: -1}" "$value" WITH_OPTIONALS && {
            _nbfc_prefix_compreply "$pre"
            return 0
          }
        done;;
  esac

  if (( ! END_OF_OPTIONS )) && [[ "$cur" = -* ]]; then
    local -a opts=()
    (( ! ${#OPT_fan} )) && opts+=(-f --fan=)
    (( ! ${#OPT_algorithm} )) && opts+=(-a --algorithm=)
    opts+=(-s --sensor=)
    (( ! ${#OPT_force} )) && opts+=(--force)
    COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    return 1
  fi

  return 1
}

_nbfc_update() {
  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_parallel OPT_quiet OPT_help OPT_version

  _nbfc_parse_commandline

  local COMP_WORDBREAKS=''

  __complete_option() {
    local opt="$1" cur="$2" mode="$3"

    case "$opt" in
      --parallel|-p)
        return 0;;
    esac

    return 1
  }

  case "$prev" in
    --*)
      __complete_option "$prev" "$cur" WITHOUT_OPTIONALS && return 0;;
    -*)
      case "$prev" in -*([qh])[p])
        __complete_option "-${prev: -1}" "$cur" WITHOUT_OPTIONALS && return 0
      esac;;
  esac

  case "$cur" in
    --*=*)
      __complete_option "${cur%%=*}" "${cur#*=}" WITH_OPTIONALS && return 0;;
    -*=*);;
    --*);;
    -*)
        local i
        for ((i=2; i <= ${#cur}; ++i)); do
          local pre="${cur:0:$i}" value="${cur:$i}"
          __complete_option "-${pre: -1}" "$value" WITH_OPTIONALS && {
            _nbfc_prefix_compreply "$pre"
            return 0
          }
        done;;
  esac

  if (( ! END_OF_OPTIONS )) && [[ "$cur" = -* ]]; then
    local -a opts=()
    (( ! ${#OPT_parallel} )) && opts+=(-p --parallel=)
    (( ! ${#OPT_quiet} )) && opts+=(-q --quiet)
    COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    return 1
  fi

  return 1
}

_nbfc_wait_for_hwmon() {
  return 0
}

_nbfc_get_model_name() {
  return 0
}

_nbfc_warranty() {
  return 0
}

_nbfc_donate() {
  return 0
}

_nbfc_help() {
  return 0
}

complete -F _nbfc nbfc

# vim: ft=sh ts=2 sts=2 sw=2 et
