# 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_service_prefix_compreply() {
  local i=0 prefix="$1"
  for ((i=0; i < ${#COMPREPLY[@]}; ++i)); do
    COMPREPLY[i]="$prefix${COMPREPLY[i]}"
  done
}

_nbfc_service_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_service)
          case "$arg" in
            --help)
              OPT_help+=(_OPT_ISSET_)
              continue;;
            --read-only)
              OPT_read_only+=(_OPT_ISSET_)
              continue;;
            --fork)
              OPT_fork+=(_OPT_ISSET_)
              continue;;
            --debug)
              OPT_debug+=(_OPT_ISSET_)
              continue;;
            --config-file)
              OPT_config_file+=("${words[++argi]}")
              continue;;
            --config-file=*)
              OPT_config_file+=("${arg#*=}")
              continue;;
            --embedded-controller)
              OPT_embedded_controller+=("${words[++argi]}")
              continue;;
            --embedded-controller=*)
              OPT_embedded_controller+=("${arg#*=}")
              continue;;
          esac
        esac
        for ((i=1; i < ${#arg}; ++i)); do
          char="${arg:$i:1}"
          trailing_chars="${arg:$((i + 1))}"
          case "$cmd" in nbfc_service)
            case "$char" in
              h)
                OPT_help+=(_OPT_ISSET_);;
              r)
                OPT_read_only+=(_OPT_ISSET_);;
              f)
                OPT_fork+=(_OPT_ISSET_);;
              d)
                OPT_debug+=(_OPT_ISSET_);;
              c)
                if [[ -n "$trailing_chars" ]]
                then OPT_config_file+=("$trailing_chars")
                else OPT_config_file+=("${words[++argi]}")
                fi
                continue 2;;
              e)
                if [[ -n "$trailing_chars" ]]
                then OPT_embedded_controller+=("$trailing_chars")
                else OPT_embedded_controller+=("${words[++argi]}")
                fi
                continue 2;;
            esac
          esac
        done;;
      *)
        POSITIONALS[POSITIONAL_NUM++]="$arg"
        ;;
    esac
  done

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

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

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

  local END_OF_OPTIONS POSITIONALS POSITIONAL_NUM
  local -a OPT_help OPT_read_only OPT_fork OPT_debug OPT_config_file OPT_embedded_controller

  _nbfc_service_parse_commandline

  local COMP_WORDBREAKS=''

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

    case "$opt" in
      --config-file|-c)
        _filedir
        return 0;;
      --embedded-controller|-e)
        COMPREPLY=($(compgen -W 'dummy dev_port ec_sys acpi_ec' -- "$cur"))
        return 0;;
    esac

    return 1
  }

  case "$prev" in
    --*)
      __complete_option "$prev" "$cur" WITHOUT_OPTIONALS && return 0;;
    -*)
      case "$prev" in -*([hrfd])[ce])
        __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_service_prefix_compreply "$pre"
            return 0
          }
        done;;
  esac

  if (( ! END_OF_OPTIONS )) && [[ "$cur" = -* ]]; then
    local -a opts=()
    (( ! ${#OPT_help} )) && opts+=(-h --help)
    (( ! ${#OPT_read_only} )) && opts+=(-r --read-only)
    (( ! ${#OPT_fork} )) && opts+=(-f --fork)
    (( ! ${#OPT_debug} )) && opts+=(-d --debug)
    (( ! ${#OPT_config_file} )) && opts+=(-c --config-file=)
    (( ! ${#OPT_embedded_controller} )) && opts+=(-e --embedded-controller=)
    COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur"))
    [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    return 1
  fi

  return 1
}

complete -F _nbfc_service nbfc_service

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