#compdef ec_probe

# 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

_ec_probe__query() {

  __zsh_query_contains() {
    local arg='' key="$1"; shift
    for arg; do [[ "$key" == "$arg" ]] && return 0; done
    return 1
  }

  local cmd="$1"; shift

  case "$cmd" in
    get_positional)
      printf "%s" "${POSITIONALS[$1]}"
      return 0;;
    init)
      local -a options=(${=1})
      shift;;
    *)
      echo "_ec_probe__query: argv[1]: invalid command" >&2
      return 1;;
  esac


  local  long_opts_with_arg=()  long_opts_with_optional_arg=()  long_opts_without_arg=()
  local short_opts_with_arg=() short_opts_with_optional_arg=() short_opts_without_arg=()

  local option=''
  for option in "${options[@]}"; do
    case "$option" in
      --?*=)    long_opts_with_arg+=("${option%=}");;
      --?*=\?)  long_opts_with_optional_arg+=("${option%=?}");;
      --?*)     long_opts_without_arg+=("$option");;
      -?=)      short_opts_with_arg+=("${option%=}");;
      -?=\?)    short_opts_with_optional_arg+=("${option%=?}");;
      -?)       short_opts_without_arg+=("$option");;
    esac
  done

  POSITIONALS=()
  HAVING_OPTIONS=()
  OPTION_VALUES=()
  INCOMPLETE_OPTION=''

  local args=("${(Q)@}")
  local argi=2 # argi[1] is program name
  for ((; argi <= ${#args[@]}; ++argi)); do
    local arg="${args[$argi]}"
    local have_trailing_arg=$(test $argi -lt $# && echo true || echo false)

    case "$arg" in
      --)
        POSITIONALS+=("${@:$((argi + 1))}")
        break;;
      --*=*)
        HAVING_OPTIONS+=("${arg%%=*}")
        OPTION_VALUES+=("${arg#*=}");;
      --*)
        if __zsh_query_contains "$arg" "${long_opts_with_arg[@]}"; then
          if $have_trailing_arg; then
            HAVING_OPTIONS+=("$arg")
            OPTION_VALUES+=("${args[$((++argi))]}")
          fi
        else
          HAVING_OPTIONS+=("$arg")
          OPTION_VALUES+=("")
        fi
        ;;
      -?*) # ignore '-'

        local i=1 arg_length=${#arg}
        for ((; i < arg_length; ++i)); do
          local option="-${arg:$i:1}"
          local trailing_chars="${arg:$((i+1))}"

          if __zsh_query_contains "$option" "${short_opts_without_arg[@]}"; then
            HAVING_OPTIONS+=("$option")
            OPTION_VALUES+=("")
          elif __zsh_query_contains "$option" "${short_opts_with_arg[@]}"; then
            if [[ -n "$trailing_chars" ]]; then
              HAVING_OPTIONS+=("$option")
              OPTION_VALUES+=("$trailing_chars")
            elif $have_trailing_arg; then
              HAVING_OPTIONS+=("$option")
              OPTION_VALUES+=("${args[$((++argi))]}")
            fi

            continue 2
          elif __zsh_query_contains "$option" "${short_opts_with_optional_arg[@]}"; then
            HAVING_OPTIONS+=("$option")
            OPTION_VALUES+=("$trailing_chars") # may be empty
            continue 2
          fi
        done
        ;;
      *)
        POSITIONALS+=("$arg");;
    esac
  done
}

_ec_probe__command() {
  local items=(
    dump:'Dump all EC registers'
    load:'Load a previously made dump into the embedded controller'
    read:'Read a byte from a EC register'
    write:'Write a byte to a EC register'
    monitor:'Monitor all EC registers for changes'
    watch:'Monitor all EC registers for changes (alternative version)'
    acpi_call:'Call an ACPI method'
    shell:'Read commands from STDIN'
  )

  _describe -- command items
}

_ec_probe() {
  local opts='-h --help -e= --embedded-controller='
  local HAVING_OPTIONS=() OPTION_VALUES=() POSITIONALS=() INCOMPLETE_OPTION=''
  _ec_probe__query init "$opts" "${words[@]}"

  case "$(_ec_probe__query get_positional 1)" in
    dump) _ec_probe_dump; return $?;;
    load) _ec_probe_load; return $?;;
    read) _ec_probe_read; return $?;;
    write) _ec_probe_write; return $?;;
    monitor) _ec_probe_monitor; return $?;;
    watch) _ec_probe_watch; return $?;;
    acpi_call) _ec_probe_acpi_call; return $?;;
    shell) _ec_probe_shell; return $?;;
  esac

  local -a args=(
    '(--help -h)'{-h,--help}'[show this help message and exit]'
    '(--embedded-controller -e)'{-e+,--embedded-controller=}'[Specify embedded controller to use]':EC:'(acpi_ec ec_sys dev_port)'
    1:command1:_ec_probe__command
  )
  _arguments -S -s -w "${args[@]}"
}

_ec_probe_dump() {
  local -a args=(
    '(--color -c)'{-c,--color}'[Force colored output]'
    '(--no-color -C)'{-C,--no-color}'[Disable colored output]'
    '(--help -h)'{-h,--help}'[show this help message and exit]'
    '(--embedded-controller -e)'{-e+,--embedded-controller=}'[Specify embedded controller to use]':EC:'(acpi_ec ec_sys dev_port)'
    1:command1:_ec_probe__command
  )
  _arguments -S -s -w "${args[@]}"
}

_ec_probe_load() {
  local -a args=(
    '(--help -h)'{-h,--help}'[show this help message and exit]'
    '(--embedded-controller -e)'{-e+,--embedded-controller=}'[Specify embedded controller to use]':EC:'(acpi_ec ec_sys dev_port)'
    1:command1:_ec_probe__command
    2:FILE:_files
  )
  _arguments -S -s -w "${args[@]}"
}

_ec_probe_read() {
  local -a args=(
    '(--word -w)'{-w,--word}'[Combine two registers into one]'
    '(--help -h)'{-h,--help}'[show this help message and exit]'
    '(--embedded-controller -e)'{-e+,--embedded-controller=}'[Specify embedded controller to use]':EC:'(acpi_ec ec_sys dev_port)'
    1:command1:_ec_probe__command
    2:'Register source':'({0..255})'
  )
  _arguments -S -s -w "${args[@]}"
}

_ec_probe_write() {
  local -a args=(
    '(--word -w)'{-w,--word}'[Combine two registers into one]'
    '(--help -h)'{-h,--help}'[show this help message and exit]'
    '(--embedded-controller -e)'{-e+,--embedded-controller=}'[Specify embedded controller to use]':EC:'(acpi_ec ec_sys dev_port)'
    1:command1:_ec_probe__command
    2:'Register destination':'({0..255})'
    3:'Value to write':"_numbers 'Value to write'"
  )
  _arguments -S -s -w "${args[@]}"
}

_ec_probe_monitor() {
  local -a args=(
    '(--interval -i)'{-i+,--interval=}'[Monitored timespan]':seconds:"_numbers -f 'Monitored timespan'"
    '(--timespan -t)'{-t+,--timespan=}'[Set poll intervall]':seconds:"_numbers 'Set poll intervall'"
    '(--report -r)'{-r+,--report=}'[Save all readings as a CSV file]':report:_files
    '(--clearly -c)'{-c,--clearly}'[Blanks out consecutive duplicate readings]'
    '(--decimal -d)'{-d,--decimal}'[Output readings in decimal format instead of hexadecimal format]'
    '(--help -h)'{-h,--help}'[show this help message and exit]'
    '(--embedded-controller -e)'{-e+,--embedded-controller=}'[Specify embedded controller to use]':EC:'(acpi_ec ec_sys dev_port)'
    1:command1:_ec_probe__command
  )
  _arguments -S -s -w "${args[@]}"
}

_ec_probe_watch() {
  local -a args=(
    '(--interval -i)'{-i+,--interval=}'[Sets the update interval in seconds]':seconds:"_numbers -f 'Sets the update interval in seconds'"
    '(--timespan -t)'{-t+,--timespan=}'[Sets how many seconds the program will run]':seconds:"_numbers 'Sets how many seconds the program will run'"
    '(--help -h)'{-h,--help}'[show this help message and exit]'
    '(--embedded-controller -e)'{-e+,--embedded-controller=}'[Specify embedded controller to use]':EC:'(acpi_ec ec_sys dev_port)'
    1:command1:_ec_probe__command
  )
  _arguments -S -s -w "${args[@]}"
}

_ec_probe_acpi_call() {
  local -a args=(
    '(--help -h)'{-h,--help}'[show this help message and exit]'
    '(--embedded-controller -e)'{-e+,--embedded-controller=}'[Specify embedded controller to use]':EC:'(acpi_ec ec_sys dev_port)'
    1:command1:_ec_probe__command
    2:'Method to call':' '
    3:'First argument':"_numbers 'First argument'"
    4:'Second argument':"_numbers 'Second argument'"
    5:'Third argument':"_numbers 'Third argument'"
    6:'Fourth argument':"_numbers 'Fourth argument'"
    7:'Fifth argument':"_numbers 'Fifth argument'"
    8:'Sixth argument':"_numbers 'Sixth argument'"
    9:'Seventh argument':"_numbers 'Seventh argument'"
    10:'Eighth argument':"_numbers 'Eighth argument'"
  )
  _arguments -S -s -w "${args[@]}"
}

_ec_probe_shell() {
  local -a args=(
    '(--help -h)'{-h,--help}'[show this help message and exit]'
    '(--embedded-controller -e)'{-e+,--embedded-controller=}'[Specify embedded controller to use]':EC:'(acpi_ec ec_sys dev_port)'
    1:command1:_ec_probe__command
  )
  _arguments -S -s -w "${args[@]}"
}

_ec_probe "$@"

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