#compdef hddfancontrol

autoload -U is-at-least

_hddfancontrol() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-v+[Level of logging output (TRACE, DEBUG, INFO, WARN, ERROR)]:VERBOSITY:_default' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_hddfancontrol_commands" \
"*::: :->hddfancontrol" \
&& ret=0
    case $state in
    (hddfancontrol)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:hddfancontrol-command-$line[1]:"
        case $line[1] in
            (daemon)
_arguments "${_arguments_options[@]}" : \
'*-d+[Drive path(s) to get temperature from (ie. \`/dev/sdX\`). Interface type selectors are also supported (ie. \`ata\` to select all drives matching \`/dev/disk/by-id/ata-*\`)]:DRIVES:_default' \
'*--drives=[Drive path(s) to get temperature from (ie. \`/dev/sdX\`). Interface type selectors are also supported (ie. \`ata\` to select all drives matching \`/dev/disk/by-id/ata-*\`)]:DRIVES:_default' \
'*-p+[PWM filepath(s) with values at which the fan start and stop moving. Use the '\''pwm-test'\'' command to find these values. Format is \`PWM_PATH\:STAT_VAL\:STOP_VAL\` (ie. \`/sys/class/hwmon/hwmonX/device/pwmY\:200\:75\`)]:PWM:_default' \
'*--pwm=[PWM filepath(s) with values at which the fan start and stop moving. Use the '\''pwm-test'\'' command to find these values. Format is \`PWM_PATH\:STAT_VAL\:STOP_VAL\` (ie. \`/sys/class/hwmon/hwmonX/device/pwmY\:200\:75\`)]:PWM:_default' \
'*-f+[Control fan speed through external command. This command will be called to set or change fan speed with the target speed passed as the first argument, as an integer between 0 and 1000, where 0 should stop the fan, and 1000 set it to its maximum speed]:FAN_CMD:_default' \
'*--fan-cmd=[Control fan speed through external command. This command will be called to set or change fan speed with the target speed passed as the first argument, as an integer between 0 and 1000, where 0 should stop the fan, and 1000 set it to its maximum speed]:FAN_CMD:_default' \
'*-t+[Temperatures in Celcius at which the fan(s) will be set to minimum/maximum speed]:TEMP:_default:TEMP:_default' \
'*--drive-temp-range=[Temperatures in Celcius at which the fan(s) will be set to minimum/maximum speed]:TEMP:_default:TEMP:_default' \
'-m+[Minimum percentage of full fan speed to set the fan to. Never set to 0 unless you have other fans to cool down your system, or a case specially designed for passive cooling]:MIN_FAN_SPEED_PRCT:_default' \
'--min-fan-speed-prct=[Minimum percentage of full fan speed to set the fan to. Never set to 0 unless you have other fans to cool down your system, or a case specially designed for passive cooling]:MIN_FAN_SPEED_PRCT:_default' \
'-i+[Interval to check temperature and adjust fan speed, ie. '\''30s'\'', '\''3min'\'']:INTERVAL:_default' \
'--interval=[Interval to check temperature and adjust fan speed, ie. '\''30s'\'', '\''3min'\'']:INTERVAL:_default' \
'-a+[Number of last temperature samples to average before computing target fan speed]:AVERAGE:_default' \
'--average=[Number of last temperature samples to average before computing target fan speed]:AVERAGE:_default' \
'*-w+[Also control fan speed according to these additional hwmon temperature probes. Format is \`HWMON_PATH\[\:TEMP_MIN_SPEED\:TEMP_MAX_SPEED\]\` (ie. \`/sys/devices/platform/coretemp.0/hwmon/hwmonX/tempY_input\:45\:75\`). If missing, target temperature range will be autodetected or use a default value. WARNING\: Don'\''t use for CPU sensors, unless you have low TDP CPU. You may also need to set a low value for -i/--interval parameter to react quickly to sudden temperature increase]:HWMONS:_default' \
'*--hwmons=[Also control fan speed according to these additional hwmon temperature probes. Format is \`HWMON_PATH\[\:TEMP_MIN_SPEED\:TEMP_MAX_SPEED\]\` (ie. \`/sys/devices/platform/coretemp.0/hwmon/hwmonX/tempY_input\:45\:75\`). If missing, target temperature range will be autodetected or use a default value. WARNING\: Don'\''t use for CPU sensors, unless you have low TDP CPU. You may also need to set a low value for -i/--interval parameter to react quickly to sudden temperature increase]:HWMONS:_default' \
'--hddtemp-daemon-port=[hddtemp daemon TCP port]:HDDTEMP_DAEMON_PORT:_default' \
'--temp-log=[Log temperature samples to a JSONL file at the given path. At every day change, log files will be compressed and rotated in the same directory]:TEMP_LOG:_files' \
'--temp-log-max-files=[Maximum number of rotated (compressed) log files to keep. When set, older files beyond this limit are deleted during daily rotation]:TEMP_LOG_MAX_FILES:_default' \
'-r[Restore fan settings on exit, otherwise the fans are run at full speed on exit]' \
'--restore-fan-settings[Restore fan settings on exit, otherwise the fans are run at full speed on exit]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(pwm-test)
_arguments "${_arguments_options[@]}" : \
'*-p+[PWM filepath(s) (ie. \`/sys/class/hwmon/hwmonX/device/pwmY\`)]:PWM:_files' \
'*--pwm=[PWM filepath(s) (ie. \`/sys/class/hwmon/hwmonX/device/pwmY\`)]:PWM:_files' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(gen-man-pages)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':dir -- Target directory (must exist):_files' \
&& ret=0
;;
(gen-shell-completions)
_arguments "${_arguments_options[@]}" : \
'-s+[Shell to generate for, leave empty for all]:SHELL:(bash elvish fish powershell zsh)' \
'--shell=[Shell to generate for, leave empty for all]:SHELL:(bash elvish fish powershell zsh)' \
'-h[Print help]' \
'--help[Print help]' \
'::dir -- Target directory to generate all shell completions into:_files' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_hddfancontrol__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:hddfancontrol-help-command-$line[1]:"
        case $line[1] in
            (daemon)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(pwm-test)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(gen-man-pages)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(gen-shell-completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_hddfancontrol_commands] )) ||
_hddfancontrol_commands() {
    local commands; commands=(
'daemon:Start fan control daemon' \
'pwm-test:Test PWM to find start/stop fan values' \
'gen-man-pages:Generate man pages' \
'gen-shell-completions:Generate shell completion' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'hddfancontrol commands' commands "$@"
}
(( $+functions[_hddfancontrol__daemon_commands] )) ||
_hddfancontrol__daemon_commands() {
    local commands; commands=()
    _describe -t commands 'hddfancontrol daemon commands' commands "$@"
}
(( $+functions[_hddfancontrol__gen-man-pages_commands] )) ||
_hddfancontrol__gen-man-pages_commands() {
    local commands; commands=()
    _describe -t commands 'hddfancontrol gen-man-pages commands' commands "$@"
}
(( $+functions[_hddfancontrol__gen-shell-completions_commands] )) ||
_hddfancontrol__gen-shell-completions_commands() {
    local commands; commands=()
    _describe -t commands 'hddfancontrol gen-shell-completions commands' commands "$@"
}
(( $+functions[_hddfancontrol__help_commands] )) ||
_hddfancontrol__help_commands() {
    local commands; commands=(
'daemon:Start fan control daemon' \
'pwm-test:Test PWM to find start/stop fan values' \
'gen-man-pages:Generate man pages' \
'gen-shell-completions:Generate shell completion' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'hddfancontrol help commands' commands "$@"
}
(( $+functions[_hddfancontrol__help__daemon_commands] )) ||
_hddfancontrol__help__daemon_commands() {
    local commands; commands=()
    _describe -t commands 'hddfancontrol help daemon commands' commands "$@"
}
(( $+functions[_hddfancontrol__help__gen-man-pages_commands] )) ||
_hddfancontrol__help__gen-man-pages_commands() {
    local commands; commands=()
    _describe -t commands 'hddfancontrol help gen-man-pages commands' commands "$@"
}
(( $+functions[_hddfancontrol__help__gen-shell-completions_commands] )) ||
_hddfancontrol__help__gen-shell-completions_commands() {
    local commands; commands=()
    _describe -t commands 'hddfancontrol help gen-shell-completions commands' commands "$@"
}
(( $+functions[_hddfancontrol__help__help_commands] )) ||
_hddfancontrol__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'hddfancontrol help help commands' commands "$@"
}
(( $+functions[_hddfancontrol__help__pwm-test_commands] )) ||
_hddfancontrol__help__pwm-test_commands() {
    local commands; commands=()
    _describe -t commands 'hddfancontrol help pwm-test commands' commands "$@"
}
(( $+functions[_hddfancontrol__pwm-test_commands] )) ||
_hddfancontrol__pwm-test_commands() {
    local commands; commands=()
    _describe -t commands 'hddfancontrol pwm-test commands' commands "$@"
}

if [ "$funcstack[1]" = "_hddfancontrol" ]; then
    _hddfancontrol "$@"
else
    compdef _hddfancontrol hddfancontrol
fi
